Loading in a for loop

2 visualizaciones (últimos 30 días)
Tim Johansson
Tim Johansson el 15 de Oct. de 2020
Comentada: Tim Johansson el 16 de Oct. de 2020
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 comentarios
Stephen23
Stephen23 el 15 de Oct. de 2020
Tim Johansson
Tim Johansson el 16 de Oct. de 2020
Thanks, it worked.

Iniciar sesión para comentar.

Respuestas (1)

Sudhakar Shinde
Sudhakar Shinde el 15 de Oct. de 2020
Editada: Sudhakar Shinde el 15 de Oct. de 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 comentarios
Stephen23
Stephen23 el 15 de Oct. de 2020
Or use the recommended and more versatile sprintf.
Tim Johansson
Tim Johansson el 16 de Oct. de 2020
Thanks for the help

Iniciar sesión para comentar.

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by