Matlab parametric plotting gui - vary parameters via sliders
-
11-04-2021 - |
Domanda
I often have function such as:
sin(a*w*t + p)
where:
w = natural frequency
t = time
a,p = parameters (which I can vary)
As you can see if you want to vary a,p, you can do so via the standard interface but it's not very convenient. So I thought I'd look for a GUI which has a slider for each parameter. Does such a thing exist?
I've never seen one so I thought I'd quickly write one. However, I'm worried that due to lack of time and knowledge of matlab I will cause problems such as generating too many plot commands when the slider is moved instead of just one. Of course I also have the problem that I want to specify a field where the user can specify the function e.g. by typing sin(a*w*t +p) in a text field and then specify what each variable means which I currently don't know how to do (it looks like a parsing task). Can I do this or should I go with a predefined set of functions?
Soluzione
You can find similar projects in Matlab File Exchange as example. For instance:
I didn't have a look at the code but according to the screenshots, it should help you.
Regarding the function input feature, you can use the function eval
(with a few checks on the input if you need reliability). If you want to allow any parametric variable, it may be harder.