I'm working on a user interface that relies on multiple figures, but each new figure implies new .m and .fig files, which will leave me with a lot in the end. How do I "compress" all these files into one single file?

4 件のコメント

Adam
Adam 2019 年 5 月 21 日
If you don't use GUIDE and do programmatic UIs you can have them all in one file. I would think though that a file per GUI is far better organisation than a load of GUIs all crammed into one long file where it is harder to find anything.
Rik
Rik 2019 年 5 月 21 日
I agree with Adam that a single file may be a lot harder to maintain. Speaking of hard to maintain: don't use GUIDE. Either use AppDesigner, or my guide below.
My small guide to avoid GUIDE:
  • 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.
Alexandre Cucatti dos Santos
Alexandre Cucatti dos Santos 2019 年 8 月 5 日
While I agree to those answers, I'll say my workaround was to use MATLAB Compiler, to create a single .exe file that runs the multiwindow GUI App I was working on
Adam
Adam 2019 年 8 月 6 日
If the other GUIs are launched from a main GUI then you only need to package the main GUI into an App anyway. I have done this plenty of times with multi-GUI apps. You just need a single entry point for the Matlab compiler. Indeed, I usually create a wrapper function for this purpose anyway which is not a GUI at all, but just launches my first GUI and does any other initialisation type stuff I need.

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeInteractive Control and Callbacks についてさらに検索

製品

リリース

R2016b

コメント済み:

2019 年 8 月 6 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by