Quantcast
Channel: MATLAB Central Newsreader Recent Posts
Viewing all articles
Browse latest Browse all 19628

Re: Process multiple csv files with one command

$
0
0
"Dan " <fatherdaly@gmail.com> wrote in message <kvnqp4$m1s$1@newscl01ah.mathworks.com>...
> Hi. I have a matlab script that takes a csv data file, processes the data and makes various plots. Is it possible to point matlab to a directory with many of these csv files to be processed and have it cycle through each csv file?
>
> Ideally I could set an action like this going and then just leave the computer overnight.
>
> Any help is much appreciated.

Dan

This can be achieved with a combination of the DIR command and a loop. For instance:

dname='C:\matlab_work\';
files=dir([dname,'*.csv']);

for i=1:length(files);
    csvdata=csvread([dname,files(i).name]);
    %now do something
end

Viewing all articles
Browse latest Browse all 19628

Trending Articles