Modification to GUIDE corrupts FIG-file

6 次查看(过去 30 天)
Hello,
I used GUIDE for creating a GUI and I have been using the program for 2 months and it always worked fine.
Now suddenly I get the following error message when trying to open the figure in GUIDE or trying to run the program:
Unable to read MAT-file
mydirectory/myfig.fig
File may be corrupt.
Error in graphics.internal.figfile.FigFile/read (line 25)
hgDataVars = load(filename, '-mat', '-regexp', '^hg[SO]');
Error in graphics.internal.figfile.FigFile (line 98)
obj.read(file);
Error in matlabroot\toolbox\matlab\graphics\hgload.p>hgload (line 59)
Error in openfig (line 72)
[fig, savedvisible] = hgload(filename, struct('Visible','off'));
Error in gui_mainfcn>local_openfig (line 286)
gui_hFigure = openfig(name, singleton, visible);
Error in gui_mainfcn (line 159)
gui_hFigure = local_openfig(gui_State.gui_Name, gui_SingletonOpt, gui_Visible);
Error in myfig (line 42)
gui_mainfcn(gui_State, varargin{:});
All I changed today was adding a 'save' button in the toolbar with "tools->toolbar editor". I can't even try if that caused the problem by undoing it because, as I mentioned above, I can't open the figure in GUIDE.
It would be very nice if anyone could help me.
I am using MATLAB R2013a on Windows 8.
Thank you!

采纳的回答

Image Analyst
Image Analyst 2016-4-19
Like Walter said, restore from your back up. (You do have one right? If not, you've learned a good lesson.) Better yet, time to upgrade that 3 year old version to the latest version. Or else build a new GUI from scratch and just copy and paste callback function code/contents to the new one. Not too much trouble if there's not too many controls on the window.
  1 个评论
Walter Roberson
Walter Roberson 2016-4-19
When I was systems administrator, my bosses used to be... displeased... at how much I insisted be spent on backup hardware and software. "We've never had a big problem, so is it worth it?" Back in the days when a 2 gigabyte hard drive would the budget badly. There were a couple of times when Brion or I had to rebuild the research systems from tape after the RAID drives flaked out; it did not happen often, but when it did it was a nuisance rather than a disaster.

请先登录,再进行评论。

更多回答(3 个)

Baltam
Baltam 2016-4-19
I'm no expert. But I had lots of troubles with the GUIfigs and I just downloaded a matlab 'b'-version and the problems stopped.
Kind regards,
Baltam

Nicolas Martin
Nicolas Martin 2016-4-20

Back up is love. Back up is life.

Luckily I had one not too old. But yes, I understood the importance to back up more often.

Thank you !


nicolas thorne
nicolas thorne 2016-10-11
I know this isn't helpful but Matlab needs to find a better way of allowing it's users to make GUI's, my GUIDE files are constantly getting corrupted, although I'm sure there is a good reason for it I can't seem to find information on how to fix it or on how to avoid it.
  2 个评论
Kristoffer Walker
Kristoffer Walker 2019-12-2
One way to corrupt *.fig files is to do a partial save accidentally by trying to save your *.fig file while open in GUIDE while the Matlab session is in the middle of a debugging session (where you are paused at one step in the code). This just happened to me. One also needs to be patient when moving around many objects that are selected by the mouse at one time--if you are not patient and try to close or save prematurely, you may find yourself corrupting the *.fig file.

请先登录,再进行评论。

类别

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