??? Error using ==> copyobj
Conversion to double from struct is not possible.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function uipushtool3_ClickedCallback(hObject, eventdata, handles)
% hObject handle to uipushtool3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
plotH = get(handles.axes2);
orignalAxes = gca;
% uicontrol('parent',gcf)
%Create a ne figure
newFig = figure(2);
%Create a copy of the axes
newA = copyobj(orignalAxes,newFig);
%copy the plot across
newPlotH = copyobj(plotH,newA);
%Print the fig with the print function
print(newFig,'-dpng','image.png');
%close the new figure
close(newPlotH)
guidata(hObject,handles);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Does anyone have an idea to get around this error or help me saving my plot? Any help will be appreciated.
Thanks, Markus
F=getframe(handles.axes1); %select axes in GUI
figure(); %new figure
image(F.cdata); %show selected axes in new figure
saveas(gcf, 'path', 'fig'); %save figure
close(gcf); %and close it
Export_fig allows you to specify the axes in the figure you want to save. E.g.:
export_fig(orignalAxes, 'image.png');
Download export_fig here:
http://www.mathworks.com/matlabcentral/fileexchange/23629-exportfig
I tried to use your code, but exported fig. file didn't have menu bar and toolbar.
The simplest thing that I know of is to do the following:
%set(handles.figure1, 'CurrentAxes', handles.axes3);
figure(100)
Not very elegant, but gets the job done. You can then save the figure as a .fig file using the drop down menus and not just as an image. You can also copy the figure using the drop down menu for easy inclusion in presentations.
Brad