Having Matlab run different files sequentially.

조회 수: 3 (최근 30일)
Franco
Franco 2011년 8월 1일
Ok, so I have a folder full of excel files, each file with a different name. I also wrote a program to analyze the data. I thought about manually changing the xls read command to suite the name of the file, but then I was thinking "there has to be a way for matlab to run through these files sequentially." Anyone know how to do that? Keep in mind that all of the files have different names. I would be willing to go back and change the file names to suite matlab a little better, but the gists of the thing is that I want matlab to load the file, run the program, save the data the program is supposed to extract and then move on to the next file in the sequence. Also keep in mind that I need to save the extracted data from every file. I don't want the data to go away every time a new file runs. Thanks in advance.

채택된 답변

Oleg Komarov
Oleg Komarov 2011년 8월 1일
Reference: faq 4.12
% Retrieve files in directory by extension
s = dir('C:\Users\Oleg\Desktop\*.xlsx');
% Loop over the files
names = {s.name};
for n = 1:numel(names)
xlsread(['C:\Users\Oleg\Desktop\' names{n}])
% do stuff
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by