Why do I receive an error when trying to use a figure's toolbar before MATLAB 6.1 (R12.1)?

6 views (last 30 days)
Why do I receive an error when trying to use a figure's toolbar before MATLAB 6.1 (R12.1)?
I am trying to use the toolbar in my figure, but I receive the following error:
??? Error using ==> get
Invalid handle.
Error in ==> D:\Applications\MATLABR12\toolbox\matlab\graphics\getappdata.m
On line 24 ==> value = get(h, 'ApplicationData');
Error in ==> D:\Applications\MATLABR12\toolbox\matlab\graph2d\plotedit.m
On line 135 ==> if isempty(getappdata(f,'ScribePlotEditState'))
Error in ==> D:\Applications\MATLABR12\toolbox\matlab\graph2d\scribeclearmode.m
On line 21 ==> feval(func,s{2:end});
Error in ==> D:\Applications\MATLABR12\toolbox\matlab\graph2d\plotedit.m
On line 129 ==> scribeclearmode(f,'plotedit',f,'off');
Error in ==> D:\Applications\MATLABR12\toolbox\matlab\graph2d\putdowntext.m
On line 54 ==> plotedit(fig,'on');
??? Error while evaluating uitoggletool ClickedCallback.
This happens when I try to use either of the following toolbar buttons:
Edit Plot
Insert Text
Insert Arrow
Insert Line
Zoom In
Zoom Out
Rotate 3D
To create the figure, I used the following code and sequence of events:
figure(2)
plotedit on
plotedit off
hgsave(2,'temp.fig')
close all
open('temp.fig')
Then I clicked on the Edit Plot toolbar button and received the error.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
The figure you are trying to edit was once saved when it was a figure number greater than 1, for example, 3. The creator of the figure first created the figure with an integer handle greater than 1, then enabled plot editing, and subsequently disabled it before saving the figure.
If you reopen this figure in a figure window with an integer handle less than 3, then you get an error when you attempt to interact with it using the menubar.
To avoid this problem in the future, make sure that the Edit Plot (Enable Plot Editing in MATLAB 5.3 (R11)) tool is depressed in the menubar before saving the figure.
There are three possible workarounds to fix this problem.
Workaround 1) If you can recall or guess what the integer figure number was when it was saved, execute the following commands. Make sure you are done with all of the open figures:
close all
fig = 3; % Replace 3 with your figure number
filename = 'temp.fig'; % Replace 'temp.fig' with your file name
for n=1:(fig-1)
figure('visible','off')
end
open(filename)
h=findobj(0,'type','figure','visible','off');
close(h)
You will now be able to interact with this open figure using the menubar.
Workaround 2) This workaround is a little less convenient. You can use Handle Graphics and the command line to edit your figure rather than using the plotedit tool. If you are not familiar with Handle Graphics, there is a learning curve associated with this workaround. Please read the documentation on Handle Graphics.
Workaround 3) The problem has been fixed in MATLAB 6.1. You can update your version to 6.1 and you will be able to open the figure without any toolbar problems.

More Answers (0)

Categories

Find more on Graphics Object Programming in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!