MATLAB: Batch processing unknown number of txt files

batch processingunknown number of txt files

my data are in txt format. I don't know how many txt files I will have every time before exporting them. And their names were already determined by the software when I exported them. Can I still use matlab for batch processing?

Best Answer

Of course you can batch-process using MATLAB:
S = dir(fullfile(pathname,'*.txt'));
out = cell(size(S));
for k = 1:numel(S)
filename = S(k).name;
filepath = fullfile(pathname,filename);
... do whatever with each file
out{k} = ... save any data
end
And read this for a more detailed explanation: