Matlab 参数化绘图 GUI - 通过滑块改变参数
我经常有这样的功能:
sin(a*w*t + p)
where:
w = natural frequency
t = time
a,p = parameters (which I can vary)
正如你所看到的,如果你想改变a,p,你可以通过标准接口来做到这一点,但它不是很方便。所以我想我应该寻找一个 GUI,每个参数都有一个滑块。这样的事存在吗?
我从未见过,所以我想我应该尽快写一篇。然而,我担心由于缺乏时间和对 matlab 的了解,我会导致诸如移动滑块时生成太多绘图命令而不是仅一个等问题。当然,我也有一个问题,我想指定一个字段,用户可以在其中指定函数,例如通过在文本字段中键入 sin(a*w*t +p) ,然后指定每个变量的含义,而我目前不这样做不知道该怎么做(它看起来像一个解析任务)。我可以这样做还是应该使用一组预定义的函数?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在 Matlab File Exchange 中找到类似的项目作为示例。
例如:
我没有看代码但根据屏幕截图,它应该对您有帮助。
关于函数输入功能,您可以使用函数
eval
(如果需要可靠性,可以对输入进行一些检查)。如果您想允许任何参数变量,可能会更困难。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.