Loading Files using a Loop with a predictable name pattern
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Zah
el 28 de Dic. de 2022
Hie,
I want to load files using automated loop function into my workspace with predictable name pattern
. Currently I am doing manually. Here is the photo attached for reference.
. Currently I am doing manually. Here is the photo attached for reference.1 comentario
Stephen23
el 28 de Dic. de 2022
"Currently I am doing manually."
Numbering variables like that is a sign that you are doing something wrong.
Instead of forcing pseudo-indices into variable names, you should use actual indices.
Respuesta aceptada
Stephen23
el 28 de Dic. de 2022
P = 'absolute or relative path to where the files are saved';
N = 10;
C = cell(1,N);
for k = 1:N
F = sprintf('IGP_Small_fr%d.mat',k);
C{k} = Feko_load_2DMatrix(fullfile(P,F));
end
A = cat(3,C{:}) % optional
14 comentarios
Voss
el 28 de Dic. de 2022
If you don't want to use the 3D array A, then use the cell array C.
The point is that, with either of those, you will use indexing to access your matrices, rather than creating multiple variables, each containing one matrix.
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

