Having Matlab run different files sequentially.
조회 수: 3 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
Oleg Komarov
2011년 8월 1일
% 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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!