How to import multiple files in a for loop using sprintf or other

I'am trying to import text files which have similar names in which only a number changes:
node2_200.txt, node2_250.txt, node2_300.txt, and so on in increments of 50 (can be another amount)
what i tried was the following:
n = 9
A = 250
for i=1:n
formatSpec = 'node2_%d.out';
B1 = load(sprintf(formatSpec,A));
A = A+50
end
The problem here is that the result for B1 is just the last iteration and I need a variable for each of the "n" iterations. In other words I need "n" arrays made up of each specific text file.
Any ideas??

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by