- Make a figure (with f=figure;) and look into the doc for figure which properties you want to turn off (you probably want to set Menu and Toolbar to 'none')
- Create buttons and axes and everything you need with functions like uicontrol and axes. Save the handles to each element to fields of a struct (like handles.mybutton=uicontrol(___);)
- When you've finished loading all data (and saving it to fields of your handles struct), and creating all the buttons, save your handles struct to the guidata of your figure like this guidata(handles.f,handles);. (You can also use getappdata and setappdata)
- You can set the Callback property of many objects. If you do, use a function name with an @ in front, or a char array that can be evaluated to valid code. (like @MyFunction or 'disp(''you pushed the button'')')
- Callback functions will be called with two arguments: the first is a handle to the callback object, the second is eventdata that may contain special information. To get access to your data, just use handles=guidata(gcbo);. You can replace the gcbo function with the name of the first input to your callback function if you prefer.
- More information about callbacks can be found in multiple places in the doc, for example here.
Loading and Saving Variables GUI
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I'd like to build a GUI in which some .mat files are loaded at the opening of the GUI, then some operations are performed by the user, and finally some variables are saved again as .mat files ( an updated version of the previous loaded) ready for a new run of the GUI.
I'm reading too much documentation on GUIDE, AppDesigner or programmaticaly through code and I'm very confused. I don't understand which way is the best to follow and how to set the correct strategy. Now I think I'm mixing too things, adding global variables and so on.
Since the GUI will be used by other people than me, I would like to understand how to manage the command load and save variables and which GUI environment is better to use.
Thank you for your help.
3 个评论
Stephen23
2019-9-12
I agree with Rik: it really is much easier to write your own GUI: you get more control over functionality, more flexibility (e.g. nested functions to pass data between callbacks), and more compact code. Also:
- Always obtain and refer to explicit handles for all graphics objects. Do not assume that gca, gcf, etc. will refer to the objects you need.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!