开发者

How to save boxplot automatically in Matlab?

开发者 https://www.devze.com 2023-04-10 23:03 出处:网络
When I try to save boxplot using \'saveas\' as follows X = randn(10, 10); H = boxplot(X); saveas(H, \'x.fig\');

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消