I've developed an application using the new App Designer. I'd like to have users be able to click a button and save a figure to a .fig file, or some other image format.
function ButtonSaveFigureButtonPushed(app) newfigure = figure; copyobj(app.UIAxesAP, newfigure); hgsave(newfigure, 'testFIgure.fig'); end
But that gave me the error...
Error using matlab.ui.control.UIAxes/copyElement (line 1219) Functionality not supported with UIAxes. For more information, see Graphics Support in App Designer.,/pre>
What's the best way to go about this?
I spent some time on this for my own purposes. The trick is to save the individual values from the figure into local variables to be used in a figure as follows:
h = figure; h.Visible = 'off'; x = UIAxes.XAxis.Parent.Children.XData; y = UIAxes.XAxis.Parent.Children.YData; plot(x,y) lgndName1 = UIAxes.Legend.String{1}; lgd = legend(lgndName1); lgd.Box = UIAxes.Legend.Box; lgd.Location = UIAxes.Legend.Location; h.CurrentAxes.YLabel.String = UIAxes.YLabel.String; h.CurrentAxes.YLabel.FontSize = UIAxes.YLabel.FontSize; h.CurrentAxes.XLabel.String = UIAxes.XLabel.String; h.CurrentAxes.XLabel.FontSize = UIAxes.XLabel.FontSize; h.CurrentAxes.Title.String = UIAxes.Title.String; h.CurrentAxes.Title.FontSize = UIAxes.Title.FontSize; h.CurrentAxes.XLim = [0 max(x)]; h.CurrentAxes.XLim = [0 max(y)+1]; saveas(h,SaveName,'jpg') savefig(h,SaveName) delete(h)
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.