different file name in saving images

3 ビュー (過去 30 日間)
Turbulence Analysis
Turbulence Analysis 2022 年 4 月 27 日
コメント済み: Walter Roberson 2024 年 11 月 3 日
In the below script, based on iteration numbers in for loop, I need to change Y_10, Y_20,Y_30,Y_40.....Y_100
Is there a way to achive this instead of renaming everytime ??
saveas(gcf, sprintf('Y_10mm'), 'bmp')
savefig(gcf, sprintf('Y_10mm')

採用された回答

DGM
DGM 2022 年 4 月 27 日
編集済み: DGM 2022 年 4 月 27 日
In whatever loop you're using, create the filename something like this:
k = 10 % whatever number you need
k = 10
sprintf('Y_%03dmm.bmp',k)
ans = 'Y_010mm.bmp'
Unless you have a need to avoid it, zero-pad your numbers so that your files sort correctly and are easier to read back in corresponding order
  6 件のコメント
KHAING
KHAING 2024 年 11 月 3 日
how about repeat in for loop for many series number of figure
Walter Roberson
Walter Roberson 2024 年 11 月 3 日
for h = [10 20 30]
for w = [20 21 22]
filename = sprintf('Y_%03dmm_x_%03dmm.bmp',h,w);
%some calculation
imwrite(YourImage, filename);
end
end

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by