how to deal with an error with exportgraphics

94 ビュー (過去 30 日間)
alpedhuez
alpedhuez 2022 年 7 月 9 日
コメント済み: alpedhuez 2022 年 7 月 9 日
I write something like
pl=plot(x,y)
hold on
plot(x,z)
hold off
legend('test')
(some other code for axis information)
exportgraphics(pl, 'test.tif', 'ContentType','vector')
Then got an error message
"Error using exportgraphics
The value of 'handle' is invalid. Specified handle is not valid for export."
What shall I do?

採用された回答

Image Analyst
Image Analyst 2022 年 7 月 9 日
Your pl is a handle to the curve that plot drew. It's not the handle to the entire graph. The last axes you drew to is called gca, so try
exportgraphics(gca, 'test.tif', 'ContentType','vector')

その他の回答 (1 件)

Jan
Jan 2022 年 7 月 9 日
編集済み: Jan 2022 年 7 月 9 日
As the documentation says, the handle must be:
axes | figure | standalone visualization | tiled chart layout | ...
plot replies a line-object. Solution:
AxesH = axes;
pl=plot(x,y)
...
exportgraphics(AxesH, 'test.tif', 'ContentType','vector')
If you get an error message, read it carefully and compare it with the details given in the documentation:
doc exportgraphics
"The value of 'handle' is invalid" means, that the 1st input is the problem. So check, what is expected as 1st input.

カテゴリ

Help Center および File ExchangeLabels and Annotations についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by