How can I embed my .m file(function) in my GUI?

7 views (last 30 days)
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
jd fnsl
jd fnsl on 8 Nov 2017
Thank you very much for your response. I would like to clear things on what I was trying to say.
  1. By saying "functional input", I want user to give any variable function e.g.- y=x^2+3 and it should plot y w.r.t. x. What I'm trying to do is to take 3 different inputs in x,y,z variables only, and at the and I want to plot these inputs wrt x,y, or z.
  2. Second thing I don't wnt a numerical input rather I want a variable input which I can plot.
  3. user will provide input in the 'Editable Text Box'.
Adam
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.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 8 Nov 2017
Provided that you do not need to compile your code, there are two basic approaches:
  1. use str2func() to create an anonymous function. This is usually fine for numeric work.
  2. use the symbolic toolbox. In R2017b, use str2sym; in earlier versions use sym() (you might get a warning.)
  3. you might also be able to use inline(), but this is not recommended.

More Answers (1)

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!