How can I embed my .m file(function) in my GUI?
7 views (last 30 days)
Show older comments
I am trying to make a GUI which can take functional inputs from the user and can plot various graphs and contours based on the input by the user. I'm not able to find some inbuilt command which I can use directly.
5 Comments
Adam
on 8 Nov 2017
Sounds like what you are expecting is a full-blown parser. I'm not aware that anything in base Matlab can handle equations written like that. Maybe the Symbolic Toolbox can.
doc fplot
can do some plotting of a function, but it needs a function handle as far as I understand, not an equation in a string.
Accepted Answer
Walter Roberson
on 8 Nov 2017
Provided that you do not need to compile your code, there are two basic approaches:
- use str2func() to create an anonymous function. This is usually fine for numeric work.
- use the symbolic toolbox. In R2017b, use str2sym; in earlier versions use sym() (you might get a warning.)
- you might also be able to use inline(), but this is not recommended.
0 Comments
More Answers (1)
See Also
Categories
Find more on Entering Commands in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!