Loading in a for loop

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?

Answers (1)

Sudhakar Shinde
Sudhakar Shinde on 15 Oct 2020
Edited: Sudhakar Shinde on 15 Oct 2020
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 Comments

Or use the recommended and more versatile sprintf.
Thanks for the help

Sign in to comment.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Asked:

on 15 Oct 2020

Commented:

on 16 Oct 2020

Community Treasure Hunt

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

Start Hunting!