changing string in a for loop
显示 更早的评论
I have a script that reads the titles of ID's right now I have the MATLAB set up to read one at a time by typing the ID number as a string.
str = 'ID_01'
I want to add a for loop to change the string to ID_02, ID_03,... to ID_100.
回答(1 个)
Cris LaPierre
2020-8-17
for n = 1:100
str = sprintf("ID_%02d",n);
end
1 个评论
Walter Roberson
2020-8-17
Or
str = compose('ID_%02d', n)
类别
在 帮助中心 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!