如何在Matlab中自动保存箱线图?
当我尝试使用“saveas”保存箱线图时,如下所示,
X = randn(10, 10);
H = boxplot(X);
saveas(H, 'x.fig');
我收到错误
??? Error using ==> saveas at 72
Simulink object array must be a vector.
此错误显示是因为 H 是箱线图中线条的句柄矩阵,但 saveas 要求 H 是单个句柄。有人可以告诉我如何使用命令保存箱线图吗?谢谢。
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 72
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SAVEAS 需要一个图形句柄作为其第一个输入。 BOXPLOT 与大多数其他绘图函数一样,返回绘制图形的句柄对象,但不是图形句柄。
因此,您应该编写
saveas(gcf,'x.fig')
,它使用 GCF 查询当前图窗的句柄,即已绘制箱线图的图窗。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.