automation - How to run the same code with many files (different file name in same directory) in Matlab? -


i have thousand .dat files run same program. there faster way or script run automatically instead of run them 1 one? .dat files have different filenames.

the program like:

fid=fopen('**abd**.dat'); c=textscan(...); ... save('**abd**.txt',data); 

the abd file name. have thousands of files different file names. bit annoying keep copying , pasting filenames program , run it. got faster way or code this?

you can use "dir" list of files, , process them in loop this.

fns = dir('*.dat'); = 1:length(fns)     fid = fopen(fns(i).name);     c = textscan(...);     fclose(fid);     save([fns(i).name,'.dat'],data);  end 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -