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

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?

6 Comments

I am having the same problems.
Hi Jason,
Were you able to find a way around this problem.
Hi Santosh,
Yes, in my case, the problem was that the *.m file assocated with the GUI was not updated automatically when editting the GUI layout, and any changes made can't be saved accordingly. To sovle this, you may want to close the *.m file when editting GUI layout. After you edit and save GUI, then open *.m file to add codes if needed.
This is a little weird, because my colleague doesn't have any problem when editting GUI and *.m file simultaneously. I guess it is specific to my computer settings. Hope this can help.
Hi Jason,
The problem for me is that I get the above mentioned error upon my first save. So I cannot even create a proper .m file without encountering this problem.
What is the version of Matlab you are using. I am using R2012B (8.0.0.783)
Time to use the debugger and investigate what kind of array is there instead of a structure array.
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 7.12.0.635 (R2011a)
Operating System: Microsoft Windows 7 Version 6.1 (Build 7601: Service Pack 1)

Sign in to comment.

Answers (2)

You cannot run .fig files; you must run the corresponding .m file.
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.

Categories

Products

Tags

Asked:

on 15 May 2013

Answered:

on 15 Aug 2018

Community Treasure Hunt

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

Start Hunting!