MATLAB Answers

0

How to import data for multiple files in "for" loop?

Asked by Ismail Qeshta on 10 Nov 2017
Latest activity Commented on by Ismail Qeshta on 13 Nov 2017
Hi, I would like to import data from multiple files using "for" loop. The files follow the seuquene of Data11, Data12, Data13, etc. I tried using the following command, but it is showing an error:
c = [1 2 3 4 5 6 7 8 9 10];
s = [1 2 3 4 5 6 7 8 9 10];
for i=1:10;
for j=1:10;
b=importdata('Data(c(i)s(j)).out');
a=importdata('Data(c(i)s(j)).out');
x= a(:,2);
y= -sum(b(:,2:11),2);
end
end
Can anyone please help me in fixing it, or let me know about the correct code.
Thank you. Regards, Ismail

  4 Comments

Show 1 older comment
Hi Stephen,
Thanks for your answer and links. The problem is that my files names are in the sequence of 11, 12, 13, etc. Does that apply to the normal sequentially numbered files as explained in the example?
Thank you very much Stephen

Sign in to comment.

1 Answer

Answer by Dishant Arora on 10 Nov 2017
 Accepted Answer

  1 Comment

Sign in to comment.