After saving my figure to a FIG file, why do I get an error about an "Invalid field name component" when trying to open it?

조회 수: 4 (최근 30일)
I am able to open the saved figure the first time, but I get an error on the second try.
Using OPENFIG,
hf = figure;
surf(peaks);
drawnow
hgsave(hf,'test1-bad.fig');
close(hf)
hf=openfig('test1-bad.fig')
close(hf)
hf=openfig('test1-bad.fig')
I get the following error:
??? Error using ==> subsref
Invalid field name component.
Error in ==> D:\Applications\MATLABR12p1\toolbox\matlab\graphics\getappdata.m
On line 27 ==> value = subsref(value,struct('type','.','subs',name));
Error in ==> D:\Applications\MATLABR12p1\toolbox\matlab\graphics\openfig.m
On line 50 ==> figs = getappdata(0, TOKEN);
Using OPEN,
hf = figure;
surf(peaks);
drawnow
hgsave(hf,'test2-bad.fig');
close(hf)
hf=open('test2-bad.fig')
close(hf)
hf=open('test1-bad.fig')
I get the following error:
??? Error using ==> open
Invalid field name component.

채택된 답변

MathWorks Support Team
MathWorks Support Team 2009년 6월 27일
This bug has been fixed for Release 14 SP1 (R14SP1). For previous releases, read below for any possible workarounds:
This is a bug in MATLAB 6.5 (R13) and previous versions.
The problem is related to the characters used to name the FIG file. As a general rule, any file name that passes the ISVARNAME test will not cause this problem. see the documentation on ISVARNAME for more information.
As a workaround, you can rename the FIG file such that it passes the ISVARNAME test, and restart MATLAB. You will then be able to open the file without any problems.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by