save figure with filename from a cellarray

Hello. I have coordinate (X,Y) for a plot. I want to save the scatter plot using filename from another cellarray. I used this code: scatter(X,Y); savefig(Stncode(j,1),'.fig'); It returns an error : Error using savefig (line 35) H must be an array of handles to valid figures. How to save? I get the plot but I can't save the plot.
Thanks.

 採用された回答

Image Analyst
Image Analyst 2014 年 12 月 7 日

0 投票

See the FAQ for good info on how to use cell arrays http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F
If the filename is in another cell array like you said, then you can get the filename string from the cell array with braces:
filename = otherCellArray{index};
savefig(gcf, filename);

1 件のコメント

Bharat
Bharat 2014 年 12 月 7 日
Hey, thanks man!. And i already tried {}. Didn't work. What was different from your code was the gcf.

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

その他の回答 (0 件)

カテゴリ

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

タグ

質問済み:

2014 年 12 月 7 日

コメント済み:

2014 年 12 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by