changing string in a for loop

12 Ansichten (letzte 30 Tage)
Desmond Hutchinson
Desmond Hutchinson am 17 Aug. 2020
Kommentiert: Walter Roberson am 17 Aug. 2020
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.

Antworten (1)

Cris LaPierre
Cris LaPierre am 17 Aug. 2020
for n = 1:100
str = sprintf("ID_%02d",n);
end

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by