フィルターのクリア

How to make sure number of digits remain same, padded if required

1 回表示 (過去 30 日間)
Mohana Singh
Mohana Singh 2019 年 4 月 22 日
編集済み: JULIEN BARBAUD 2019 年 4 月 22 日
I am assigning names in a loop of the form img000.png,img001.png and so on. I’m using strcat as follows:
%num=000 %strcat(‘img’,num2str(num),’.png’) %num=+1
How do I make the assignment of num so that it always remains 3 digits?

採用された回答

JULIEN BARBAUD
JULIEN BARBAUD 2019 年 4 月 22 日
編集済み: JULIEN BARBAUD 2019 年 4 月 22 日
Try to use something like
img_name=sprintf('img%03d',num)
instead of the strcat line

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by