MATLAB Answers


Saving axes to file - trouble with copyobj and export_fig

Asked by Cayleigh
on 23 Jul 2013
Latest activity Answered by Oliver Woodford
on 2 Jan 2014

I need to save a plot from an axes in my GUI. I have read every answer I can find on this and the two most promising solutions seem to be export_fig and copyobj. I've tried both to no avail.

First, using export_fig I get the error: "Undefined function or method 'print2array' for input arguments of type 'double'. Error in ==> export_fig at 334 [A,tcol] = print2array(fig,magnify,renderer);

I was hoping to use copy object instead, and tried the following code:

h1 = get(handles.efficiency_graph);
fig = figure;
newAxes = copyobj(h1,fig);

at this point, I get the error : "Error using ==> copyobj Conversion to double from struct is not possible"

Why won't my axes handle work properly with copyobj? I've seen code where the plot itself is given a handle as it is generated and that is used instead, but my plots are generated within a different callback function, and are generated as part of a for loop anyways so I'm not sure how I would do that.

Any help would be greatly appreciated!



No products are associated with this question.

1 Answer

Answer by Oliver Woodford
on 2 Jan 2014

Regarding the error using export_fig, it seems you didn't install the package correctly.


Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!