How to save a figure to png file format?

I have a figure list: ... figure, for n=1:2:length(line2) In=imcrop(Ik,[line2(n) 1 line2(n+1)-line2(n) bar1]); subplot(1,length(line2)/2,kk); imshow(In); imwrite(In,'ekstraksi_pp.jpg'); kk=kk+1; end ...
savefig('figure.fig'); hgexport('image.png');
the savefig can work but the hgexport can't. after save it as a png image i want to show it in an axes. but the hgexport can't work in the first place.
It says the error: First argument must be a handle to a figure.
I will be grateful for any help. Thankyou.

回答 (2 件)

Mike Garrity
Mike Garrity 2015 年 6 月 25 日

0 投票

That error message is trying to say that the syntax for hgexport is this:
hgexport(gcf,'image.png')

1 件のコメント

Ria Anggraini
Ria Anggraini 2015 年 6 月 25 日
I've try that way but it said:
Error using isappdata Invalid object handle

サインインしてコメントする。

Jan
Jan 2015 年 6 月 25 日

0 投票

Whenever you have a problem with a command, read the corresponding help file: doc hgsave. There you find:
hgexport(h, filename)
The forum is powerful, but the documentation is faster.

カテゴリ

ヘルプ センター および File ExchangePrinting and Saving についてさらに検索

質問済み:

2015 年 6 月 25 日

回答済み:

Jan
2015 年 6 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by