MATLAB Answers

error in GUI: Attempt to reference field of non structure array

30 views (last 30 days)
Jason on 15 May 2013
Answered: Rotem Mairon on 15 Aug 2018
I am learning to create a GUI and just adding several Static Text, Edit Text and Pop-up Menu boxes on a blank layout. After resizing and changing some properties of these boxes, I tried to run the GUI, and got the following error:
Attempt to reference field of non structure array.
Error in guidefunc>getGuiStatus (line 575) if layouted.isDirty
Error in guidefunc>saveBeforeAction (line 2525) status = getGuiStatus(fig)
Errror in guidefunc (line 13) varargout = layoutActivate(varargin{:});
It seemed that the *.fig was not saved before running, however, when I tried to save the *.fig file, there are some other errors:
Attempt to reference field of non structure array
Error in guidefunc>layoutSave(line 1224) frame = layout_ed.getFrame;
Errror in guidefunc (line 119) varargout = layoutSave(varargin{:});
I have not added/edited any Matlab codes of the GUI yet, just adding some text boxes and changing the properties, so it is really puzzling to me why these errors occurred.
Any comments?
Andreas Schmid
Andreas Schmid on 24 Sep 2013
I face a similar problem, I can't access callbacks etc from the GUIDE anymore. The error is on line 572 of the guidefunc.m file. The problem is that the code below returns an empty array:
getappdata(fig, 'GUIDELayoutEditor');
MATLAB Version (R2011a)
Operating System: Microsoft Windows 7 Version 6.1 (Build 7601: Service Pack 1)

Sign in to comment.

Answers (2)

Walter Roberson
Walter Roberson on 21 May 2013
You cannot run .fig files; you must run the corresponding .m file.

Rotem Mairon
Rotem Mairon on 15 Aug 2018
The following worked out for me: Your gui.fig should have an accompanying gui.m file. First, backup this file, then delete it. Now, try to open your gui.fig by running:
guidata gui.fig
Try to make some change to the gui layout so that the 'save' button becomes available. Then, save the file and get your gui.m file back in place. At this point things should work again.
  • I realize this has been asked quite a while ago, but with 39 views the last 30 days (while writing these words) I hope it might help others.



Community Treasure Hunt

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

Start Hunting!