【发布时间】:2014-02-03 15:52:43
【问题描述】:
我正在尝试在 Matlab 中编写一个代码,该代码将生成一个图形,然后将图形保存或导出到我的目录中。我使用的代码如下:
h = figure('name','HousingIndex');
plot(quarter,indexSample,quarter,indexSubsample);
legend('Index Sample','Index Repeat Subsample');
title('Housing Index');
xlabel('Quarter');
ylabel('Index');
其中“季度”是 1×75 的连续季度向量,“indexSample”和“indexSubsample”是 1×75 的索引值向量。但是,当我尝试使用 hgexport 函数导出图形时:
hgexport(h,'HousingIndex.jpg');
我收到以下错误消息:
??? Error using ==> hgexport at 140
First argument must be a handle to a figure.
我也尝试过使用 saveas 函数:
saveas(h,'HousingIndex.jpg')
我收到以下错误消息:
??? Error using ==> saveas at 59
Invalid handle.
这两个错误都表明我的句柄无效。我将非常感谢一个关于为什么我得到一个无效句柄的描述性答案以及这个问题的解决方案。
【问题讨论】:
-
哪个版本的 Matlab?
标签: matlab save export figure save-as