save variables in Matlab GUI
2 次查看(过去 30 天)
显示 更早的评论
hello;
if I want to save some constant
x=100;
y= 200;
how I save them in the Matlab GUI code as seen below
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/919804/image.png)
0 个评论
回答(1 个)
Rik
2022-3-9
For general advice and examples for how to create a GUI (and avoid using GUIDE), have look at this thread.
With your current setup you can store them in the guidata:
handles.x=100;
handles.y=200;
guidata(handles.figure,handles)
10 个评论
Stephen23
2022-3-10
编辑:Stephen23
2022-3-10
"so is it impossible to do it?"
I doubt that it would be impossible, but it is unlikely to be good data design or good code.
Accessing the property of a class or field of structure would be simpler. Or perhaps a basic array...
"if I want to save some constant"
Where? In the base workspace or in one of the GUI workspaces or somewhere else?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!