how to deal with an error with exportgraphics
조회 수: 93 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
채택된 답변
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
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 Exchange에서 Labels and Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!