Bob
Bob

Reputation: 21

looping and ordering extracted data in MatLab

I have hundreds of data files, named file001~file400 for example, and should pick a numeric value from each. I know how to pick each number, but, since there are too many files, I need to loop the command and order all extracted numbers with regard to the number of corresponding file. I appreciate any help.

Upvotes: 0

Views: 62

Answers (1)

riklund
riklund

Reputation: 1071

The problem is to loop over all files. This can be done in the following way:

for i = 1:400
    filename = sprintf('file%03d',i);
    // do the number picking, etc. using the filename.
end

EDIT: Per request, for filenames FT00100 to FT05320, we we make two small changes, one in the loop range and one in the first parameter to sprintf:

for i = 100:5320
    filename = sprintf('FT%05d',i);
    // do the number picking, etc. using the filename.
end

Upvotes: 1

Related Questions