changing string in a for loop

조회 수: 14 (최근 30일)
Desmond Hutchinson
Desmond Hutchinson 2020년 8월 17일
댓글: Walter Roberson 2020년 8월 17일
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
Cris LaPierre 2020년 8월 17일
for n = 1:100
str = sprintf("ID_%02d",n);
end

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by