将变量及其内容从工作区传递到 MATLAB 中的 GUI 函数
我的 MATLAB 工作区中有一个变量,我想将变量名称及其内容传递给 GUI 中的函数。
我如何完成这个任务?
I have a variable in the MATLAB workspace and I want to pass the variable name and its contents to a function in my GUI.
How do I achieve this task?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当您说“传递变量名称及其内容”时,我不完全确定您的意思,但这是一种可能的解决方案。将一组数据传递给函数后,如下所示:
您可以使用 INPUTNAME:
编辑: 正如 High Performance Mark 的评论中所指出的,变量
inputArgument
函数内部将包含存储在调用者工作区的变量data
中的值。I'm not totally sure what you mean when you say "pass the variable name and its contents", but here's one possible solution. After you pass a set of data to a function like so:
You can get the variable name of the input argument from inside the function using INPUTNAME:
EDIT: As pointed out in a comment by High Performance Mark, the variable
inputArgument
inside the function will contain the values stored in the variabledata
in the workspace of the caller.如果此问题与您最近的其他问题相关,那么为什么没有将操作构建到您的 GUI 中吗?您可以使用指南创建一个按钮,并将代码放在回调函数下。
If this question is related to your other most recent question, then why not build the operation into your GUI? You can use guide to create a pushbutton, and place the code under the callback function.
我假设您已经使用 GUIDE 创建了 GUI 图形,并且您知道 GUI 对象的“标签”名称。
((1))使用GUIDE打开图形,((2))打开图形的属性检查器(选择背景,图形的浅灰色网格区域,然后双击它,使属性弹出图形的检查器), ((3)) 打开“HandleVisibility”(默认情况下,它可能设置为“回调”),((4)) 保存图形并关闭 GUIDE,最后 ((5)) 使用工作区中当前可用的一些参数从 MATLAB 控制台(或“命令行窗口”)设置 GUI 属性值。
我希望这有帮助。
最好的,
油田
I am assuming that you have created the figure with GUI using the GUIDE, and that you know the 'Tag' names of the GUI objects.
((1)) Open the figure using the GUIDE, ((2)) Open the Property Inspector for the figure (select the background, the light-gray gridded area of the figure, and double-click over it, to make the Property Inspector for the figure to pop-up), ((3)) Turn the 'HandleVisibility' 'on' (by default, it may be set as 'callback'), ((4)) Save the figure and close the GUIDE, and finally ((5)) set the GUI property values from the MATLAB Console (or "Command Window") using some parameters that are currently available on your workspace.
I hope this helps.
Best,
Y.T.