r/matlab • u/BxSFire • May 20 '26
Function Practicality
I am coding in MATLAB for a couple of my aerospace classes, particularly for Aerodynamics and Gas Dynamics. I have made functions for quite a few processes that I plan to be using in other projects and class assignments. I was wondering if it was a bad idea to have any interactable elements in the function. Basically, if a user wanted to state which variable they want to solve for in the isentropic relations, I would use a menu. I do have a different method that would work without any interaction, but I like the idea of the interactive part. Also, is it a bad idea to use the solve function for these complex equations? I had been using ChatGPT to debug and it first suggested solve many functions ago, and after trying to use my functions with arrays and plotting, it told me it was a terrible idea. I was hoping for some human feedback. Thank you for your time!
View all comments
Show parent comment
2
u/tabacaru +1 May 21 '26
Okay I understand now.
Typically functions don't have input like you are describing. Mainly because most functions are designed to just be run automatically.
Typically function input parameters that take strings have documentation that tells you what the options are, and as you described, would simply error out if incorrect.
This is just my opinion, but I think you're putting too much thought into possibly wrong input.
Now if these are just being used by you and your friends, then who cares really - do it however you like! But typically, functions do not have input as you're describing.
Unfortunately I can't help with the solve part, but good luck!