Help for GUI initializing Problem
2 ビュー (過去 30 日間)
古いコメントを表示
Dear friends
I made a GUI. At first, my gui worked correctly. Then, I decide to add a starting page where there is a pushbotomn to start main page. I fact, the pushbutton4 in the start page and will call uipanel10 in the main page for apprearing.
Here, there is a error when I want to start my gui by double click on ".fig" file as folowing:
"??? Attempt to reference field of non-structure array.
Error in ==> untitled1>pushbutton4_Callback at 6260
set(handles.uipanel10,'Visible','on');
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> untitled1 at 42
gui_mainfcn(gui_State, varargin{:});
Error in ==>
@(hObject,eventdata)untitled1('pushbutton4_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback"
but when i open ".m" or by "guide" command, the error doesn't appear.
Please help me.
Regards
1 件のコメント
Image Analyst
2019 年 8 月 25 日
You forgot ot attach your .m and .fig file, and any other files that need to be read in at run-time. We can look at it after that.
採用された回答
Rik
2019 年 8 月 25 日
You can't start a GUIDE-created GUI by opening the fig file. You need to run the function (so the m file).
<personal opinion> Don't use GUIDE for anything that takes more than 5 minutes to put together. GUIDE hasn't seen any development in years, maybe even decades, which has made it a confusing bloated mess. Either use AppDesigner, or native matlab tools.
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.
0 件のコメント
その他の回答 (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!