When I try to save boxplot using 'saveas' as follows
X = randn(10, 10);
H = boxplot(X);
saveas(H, 'x.fig');
I receive the error
??? Error using ==> saveas at 7开发者_如何学C2
Simulink object array must be a vector.
This error shows up because H is a matrix of handles to the lines in the box plot, but saveas requires H to be a single handle. Can somebody tell me how to save boxplot using command? Thanks.
SAVEAS requires a handle to a figure as its first input. BOXPLOT, like most other plotting functions, return the handles of the plotted graphical objects, but not the figure handle.
Thus, you should write saveas(gcf,'x.fig')
, which uses GCF to query the handle of the current figure, which is the figure into which the boxplot has been plotted.
精彩评论