command for copy a figure and put it in a specified folder in a specified name and then close it

1 回表示 (過去 30 日間)
anyone know how can copy a figure and put(for example in .bmp format) it in a specified folder for example:
dfile; % i have this and this is a specified name in string
lable; % i have this and this is a specified name in string
directory = ['\c:\ClassifyingResults\',lable];
h=figure.....
copy figure in .bmp (or other format) in name of ddfile_lable and
if exist~=7
put it in : directory % directory is defined above
close(h)

採用された回答

Fangjun Jiang
Fangjun Jiang 2011 年 9 月 6 日
The key function is saveas(). The others are like fullfile(), exist(File,'file').
PathStr='c:\ClassifyingResults';
directory=fullfile(PathStr,lable);
h=figure;
%plot figure
File=[dfile,'_',lable];
if exist(File,'file')
File=fullfile(directory,File);
end
saveas(h,File,'bmp');
close(h)

その他の回答 (1 件)

Paulo Silva
Paulo Silva 2011 年 9 月 6 日
spy
saveas(gcf,'spy','jpg') %save into current directory
or
dfile='c:\ClassifyingResults\'; %the directory must exist
spy
saveas(gcf,[dfile 'spy'],'jpg')
  2 件のコメント
mohammad
mohammad 2011 年 9 月 6 日
nice thanks
'spy' is nice too :)
mohammad
mohammad 2011 年 9 月 6 日
dear paulo
i asked another question like this but for subplot please help me

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

カテゴリ

Help Center および File ExchangeDiscrete Data Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by