image storage with index type 0000

1 回表示 (過去 30 日間)
Federico Paolucci
Federico Paolucci 2022 年 11 月 30 日
コメント済み: Les Beckham 2022 年 11 月 30 日
Hi, I would like to store a series of images in .bmp format and with an index starting from 0000 for the first image, 0001 for the second and so on.. this is an example of the name of one of the images i want to save : 'ortophoto_0000.bmp' can you give me some advice? thank you

回答 (1 件)

KSSV
KSSV 2022 年 11 月 30 日
編集済み: KSSV 2022 年 11 月 30 日
for i = 1:10
name = ['ortophoto_',sprintf('%.4d',i),'.bmp']
end
name = 'ortophoto_0001.bmp'
name = 'ortophoto_0002.bmp'
name = 'ortophoto_0003.bmp'
name = 'ortophoto_0004.bmp'
name = 'ortophoto_0005.bmp'
name = 'ortophoto_0006.bmp'
name = 'ortophoto_0007.bmp'
name = 'ortophoto_0008.bmp'
name = 'ortophoto_0009.bmp'
name = 'ortophoto_0010.bmp'
  1 件のコメント
Les Beckham
Les Beckham 2022 年 11 月 30 日
That works but, since you are using sprintf anyway, why not do this?
for i = 1:10
name = sprintf('orthophoto_%04d.bmp', i)
end
name = 'orthophoto_0001.bmp'
name = 'orthophoto_0002.bmp'
name = 'orthophoto_0003.bmp'
name = 'orthophoto_0004.bmp'
name = 'orthophoto_0005.bmp'
name = 'orthophoto_0006.bmp'
name = 'orthophoto_0007.bmp'
name = 'orthophoto_0008.bmp'
name = 'orthophoto_0009.bmp'
name = 'orthophoto_0010.bmp'

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

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by