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??

 採用された回答

Walter Roberson
Walter Roberson 2015 年 6 月 17 日

0 投票

B1{i} = load(sprintf(formatSpec,A));

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by