Guide GUI deleted associated *.m file

3 次查看(过去 30 天)
Jeffrey
Jeffrey 2014-11-24
回答: Orion 2014-11-24
I created a guide GUI which took me ~6-7 hours as I had not worked with the gui before and it seems matlab ended up deleting the contents of the associated m-file. Though it was first gui I think it was fairly clean and I was not doing anything weird with handles.
Contents: - Edit box, pushbutton (*3) for setting directories/files - 3 edit boxes for x,y,z of a point - uitable with 5 columns. 2 of the columns had choice lists which were filled based on the input files - listbox which was used to output things from the code (I over-rode the built in fprintf so all fprintf statements went to this listing window)
The problem started when I tried to add a callback function to the uitable. I went in the property inspector and added it by clicking the autofill button on the left and then saved the .fig file. It gave an error about referencing a nonstructured array something or other. I tried deleting the callback from the property inspector to no avail. I tried running the *.m file to use the gui and see if it still worked but nothing happened (no errors, but it didn't run). I decided to close everything and reopen matlab. When I did so the contents of the m file (which was definitely saved previously.... like last week and 5 times today) was gone. Not a single character is there. I'm at a loss for what happened here. I don't have a backup of the .m file.
Thoughts?
  1 个评论
Jeffrey
Jeffrey 2014-11-24
Upon first opening in guide everything is fine. I can change values and save the .fig file (with the .m open). If I change the code in the editor and save it I can run my gui just fine. However if I change something using the property inspector and then try to save the fig file I get the following error....
Attempt to reference field of non-structure array.
Error in guidefunc>layoutSave (line 1226) frame=layout_ed.getFrame;
Error in guidfunc (line118) varargout = layoutSave(varargin{:});

请先登录,再进行评论。

回答(2 个)

Orion
Orion 2014-11-24
Hi,
Just guessing.
Open your gui with guide
In guide toolbar.
Tools -> GUI options
is "Generate FIG-file only" selected ?
Is so, reswitch to "Generate FIG-file and M-file".
  1 个评论
Jeffrey
Jeffrey 2014-11-24
The "Generate FIG-file and M-file" option is selected. I was actually able to recode this fairly quickly as there was some snippets in other files and I was able to get guide to generate the barebones function structure of the fig file. The same behavior happened again though (I backed it up this time!). See above for update.

请先登录,再进行评论。


Orion
Orion 2014-11-24
it seems to me that you had created an object which is badly configured in the gui or which existed but you deleted it in the gui and the corresponding callbacks are still in the code.
so when you regenerate the code, guide creates the structure handles with the tag of all the controls, axes,... and it analyses the code if this one already exists in order to complete it and if there are some differences between the handles in the gui and the callbacks in the code, you can have the kind of error you get.
I don't know your gui, neither the code, and less the previous versions. so it will be pretty hard to resolve at distance.
I'd say, you should try to debug this way.
- List all the control / axes / ... in your gui and see if their is a corresponding callback.
- check if every callback in the code corresponds to a graphic object.

类别

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