error starting a GUI
조회 수: 2 (최근 30일)
이전 댓글 표시
I have developed a simple gui with radiobuttons. Everything works fine as long as I start the gui from the script and then use it. If I start directly the gui.fig file, I got this rerror message when I start using the GUI:
Struct contents reference from a non-struct array object.
Error in gui>pushbutton1_Callback (line 88)
dataSet = get(handles.errorset_groupbutton.SelectedObject,{'String','Value'})
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in gui (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)gui('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.
댓글 수: 0
채택된 답변
Rik
2018년 12월 10일
That .fig file is not the complete GUI, it is only the visible elements. The callback functions it references are not contained in the figure, so when you try to execute a function, that function can't work properly, because the guidata wasn't set correctly.
You have already identified the solution: don't start the GUI by opening the fig, but start it with the function. If you can't keep them apart, don't use a fig, but either click the 'generate code' option in GUIDE, or avoid GUIDE in the first place.
If you want some hints about avoiding GUIDE, I'dd be happy to give you some pointers about what I do (or you can just have a look at my FEX submission to see some examples).
댓글 수: 4
Rik
2018년 12월 12일
I remembered from an older version of Matlab that the button had a text like "generate code", but apparently it is called "export to MATLAB-file" (it can be found in the file dropdown in the GUIDE editor).
추가 답변 (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!