Image file saving location

5 ビュー (過去 30 日間)
형준 이
형준 이 2022 年 5 月 19 日
コメント済み: 형준 이 2022 年 5 月 19 日
my code ↓
for i = 1:5
h = imagesc(X, Y, Z(:,:,i)); xlim([-2 2]); ylim([-1 1]);
fname = ['Image', num2str(i)];
print(fname, '-djpeg');
end
How do I save the image file to folder 'C:\Users\leehj\Desktop\aaa' ?

採用された回答

Walter Roberson
Walter Roberson 2022 年 5 月 19 日
outdir = 'C:\Users\leehj\Desktop\aaa';
for i = 1:5
h = imagesc(X, Y, Z(:,:,i)); xlim([-2 2]); ylim([-1 1]);
fname = fullfile(outdir, ['Image', num2str(i)]);
print(fname, '-djpeg');
end
  2 件のコメント
Walter Roberson
Walter Roberson 2022 年 5 月 19 日
編集済み: Walter Roberson 2022 年 5 月 19 日
Note: with modern MATLAB, you should consider using exportgraphics() .
Also you should probably include the file extension.
There are also nicer ways to construct the name,
outdir = "C:\Users\leehj\Desktop\aaa";
ax = gca;
for i = 1:5
imagesc(ax, X, Y, Z(:,:,i)); xlim([-2 2]); ylim([-1 1]);
fname = fullfile(outdir, "Image" + i + ".jpg");
exportgraphics(ax, fname);
end
형준 이
형준 이 2022 年 5 月 19 日
thank you ver much :- )

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

その他の回答 (1 件)

KSSV
KSSV 2022 年 5 月 19 日
thepath = 'C:\Users\leehj\Desktop\aaa\' ;
for i = 1:5
h = imagesc(X, Y, Z(:,:,i)); xlim([-2 2]); ylim([-1 1]);
fname = [thepath,'Image', num2str(i)];
print(fname, '-djpeg');
end
  1 件のコメント
형준 이
형준 이 2022 年 5 月 19 日
thank you ver much :- )

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

カテゴリ

Help Center および File ExchangeImage Segmentation and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by