Monday 15 March 2010

import - Importing Multiple text File to Matlab -



import - Importing Multiple text File to Matlab -

i need import text files matrix in matlab. can help me code please? here text file names.

elist_s06n1.txt elist_s06n2.txt elist_s06n3.txt elist_s06n4.txt elist_s07n1.txt elist_s07n2.txt elist_s07n3.txt elist_s07n4.txt . . . elist_s27n5.txt

so, till elist_s09n1.tx n going 1 through 4, going 1 through 5.

thank in advance.

thanks update can see have tried far.

it seems me have difficulties generating proper filename. instead of looping on cell array index, utilize 2 loops, 1 6 27 , other 1 4 or 5. based on these values, can generate desired filename (mind leading zero!). within loop, maintain track of index resulting cell array.

by way, if count number of files, arrive @ total of 18*5 + 4*4 = 106 , not 95.

the code:

numfiles = (27-9)*5 + (9-5)*4; mydata = cell(1, numfiles); idx = 0; % index mydata n = 4; k1 = 6:27 if k1 == 10 n = 5; % switch 5 files if k1 reaches 10 end k2 = 1:n idx = idx+1; myfilename = sprintf('elist_s%02dn%d.txt', k1, k2); mydata{idx} = importdata(myfilename); end end

matlab import

No comments:

Post a Comment