필터 지우기
필터 지우기

Error: Attempt to reference field of non-structure array.

조회 수: 4 (최근 30일)
Peng Zhao
Peng Zhao 2017년 10월 3일
댓글: Stephen 2017년 10월 5일
Hello, I am writing a small project with GUI and had this error while running the .fig file. This error does not happen when I click run while the .m file is open, only if I start directly from the .fig file.
Attempt to reference field of non-structure array.
Error in But_Disable (line 3)
Error in Minesweeper>Start_Callback (line 27)
But_Disable
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in Minesweeper (line 15)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)Minesweeper('Start_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
Please help me to see what is the problem, thanks. The files have been attached within the .zip file.
  댓글 수: 3
Walter Roberson
Walter Roberson 2017년 10월 4일
It is possible to create a .fig file in which all the code was stored as anonymous functions or as strings: such a .fig could run "without opening any .m". It would not be practical. A number of years ago, a fellow wrote an entire novel without using the letter "e", just to show it could be done: it was possible, but not very useful.
All code that affects the screen must run in the foreground. It is possible, using the Parallel Computing Toolbox, to run code in another worker, but those workers cannot change the display.
Stephen
Stephen 2017년 10월 5일
Are you worried about the .m file being visible, or are you worried about a name clash with another function?

댓글을 달려면 로그인하십시오.

채택된 답변

Stephen
Stephen 2017년 10월 3일
The .fig file is not a stand-alone GUI. The like named .m file instantiates the .fig as a GUI. The .fig is like a structure for building GUI rules, while the .m file contains the GUI functions and rules. So when you press the run button on fig without the .m file, it's probably passing a different input to the function than you would expect.
  댓글 수: 1
Walter Roberson
Walter Roberson 2017년 10월 3일
Right. GUIDE is not designed to be able to execute the .fig file.
It is theoretically possible to build a .fig that can initialize properly when the .fig is run instead of the .mat file, but I have never seen it done outside of my own experimentation to prove it possible.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by