MATLAB Answers

How can i read multiples files from a directory?

1 view (last 30 days)
ellis
ellis on 10 Mar 2015
I have used a loop but i get only the content of the last file. Can someone help me? Thanks in advance

  0 Comments

Sign in to comment.

Answers (1)

Giorgos Papakonstantinou
Giorgos Papakonstantinou on 10 Mar 2015
Assuming you want to open a few files. Create a cell|filenames|. Then the loop would be like this>
filenames = {'file1.txt' 'file10.txt' 'file11.txt'};
for ii=1:length(filenames)
fid = fopen(char(filenames(ii)));
.... % here you can do textscan for example
fclose(fid);
end

  0 Comments

Sign in to comment.

Sign in to answer this question.