Filter löschen
Filter löschen

while opening a figure file (.fig) in matlab , I get an error "error using ==> open at 159 invalid figure file format".

20 Ansichten (letzte 30 Tage)
while opening a figure file (.fig) in matlab , I get an error "error using ==> open at 159 invalid figure file format". Original figure files were made in MATLAB 2015 version but i tried it opening in I tried it in MATLAB 2015, 2008,2007 and none of them worked. i keep getting the error for all the fig. files.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 6 Okt. 2016
Please post a sample file.
.fig files created by R2014b or later use a different format than earlier versions. I did some research on this a couple of months ago and recall that there is code to allow fairly old files to be opened in new versions, but by default the new files would not be readable by the old. At the moment I do not recall if there is a way of saving for backwards compatibility.
The new files use a completely different data structure than the old to represent graphics so do not expect it to be easy.
Mathworks seldom promises backwards compatibility of object oriented data, only of plain numeric data and character vectors and logical and structures.

Weitere Antworten (1)

Frank Macias-Escriva
Frank Macias-Escriva am 10 Jan. 2017
Recently I had a similar situation, I made some enhancements to a GUI in 2015a and 2016a, later I tried to use it in 2009b, and I got the error that you refer. In my case I solved it with the following steps:
Let's say the "offending" file is myGUI.fig:
  1. Make a backup, just in case.
  2. Run the following code:
load -mat myGUI.fig;
save myGUI.fig hgS_070000 -mat;
  1. Run/Open to test the results
You can explore also with other methods, as renaming from .fig to .mat (they are stored in -mat format!), import the data and see the difference between the old and new versions of .fig files, in my experience: the new format adds a new variable, hgM_070000. Then it will be enough if you save only the hgS_070000 variable to the same .mat filename, and later rename the file back to .fig.
I hope this can help, since my only concern is your comment that you "made it in 2015, and it didn't work in 2015".
======
NOTE: You will be in this situation if you try A or B bellow:
A) If you try to run the associated .m file you will get:
??? Error using ==> hgload at 53
invalid Figure file format
Error in ==> openfig at 72
[fig, savedvisible] = hgload(filename, struct('Visible','off'));
Error in ==> gui_mainfcn>local_openfig at 286
gui_hFigure = openfig(name, singleton, visible);
Error in ==> gui_mainfcn at 159
gui_hFigure = local_openfig(gui_State.gui_Name, gui_SingletonOpt, gui_Visible);
Error in ==> myGUI at 65
gui_mainfcn(gui_State, varargin{:});
B) If you try to "open" your .fig file (actually it runs the GUI), you will get an Error Dialog:
"Error using ==> open at 159 invalid Figure file format"
  3 Kommentare
Nobuo Fujinaga
Nobuo Fujinaga am 30 Jul. 2019
Bearbeitet: Nobuo Fujinaga am 30 Jul. 2019
I accidentaly opened R2009a ".fig" file in R2017a, and saved it. After that I could not open .fig file in 2009a. Today I could open R2017a ".fig" file in R2009a by your procedure. Thank you very much.
mechE
mechE am 27 Mär. 2020
On using these two commands
load -mat myGUI.fig;
save myGUI.fig hgS_070000 -mat;
I am still getting the same error. I have to open a figure prepared in Matlab 2018 into Matlab 2014a. Can you please guide?
On opening the new figure it displays as, hgM_070000 and hgS_070000 and the older one as hgS_070000 only. However I'm getting the same error while opening the figure file. Am I doing something wrong?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by