Loading in a for loop

조회 수: 14 (최근 30일)
Tim Johansson
Tim Johansson 2020년 10월 15일
댓글: Tim Johansson 2020년 10월 16일
im in a situation on which i have to load a lot of files (about 400) and was wondering if there were a smart way to do it.
I was thinking that a for loop was the best way to do it, but the for loop does not recognise the 'i' as the variable.
for i=1:400
run_i='C:\Users\unknown\run_i'
end
is there a simple way to solve this?
  댓글 수: 2
Stephen23
Stephen23 2020년 10월 15일
Tim Johansson
Tim Johansson 2020년 10월 16일
Thanks, it worked.

댓글을 달려면 로그인하십시오.

답변 (1개)

Sudhakar Shinde
Sudhakar Shinde 2020년 10월 15일
편집: Sudhakar Shinde 2020년 10월 15일
You can use 'int2str'
for i=1:400
run_i=['C:\Users\unknown\run_',int2str(i)];
end
%or
for i=1:400
run_i=strcat('C:\Users\unknown\run_',num2str(i));
end
  댓글 수: 2
Stephen23
Stephen23 2020년 10월 15일
Or use the recommended and more versatile sprintf.
Tim Johansson
Tim Johansson 2020년 10월 16일
Thanks for the help

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by