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에 대해 자세히 알아보기

질문:

2015년 6월 17일

댓글:

2015년 6월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by