Having Matlab run different files sequentially.

2 次查看(过去 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.

采纳的回答

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