Is there a way to create a loop for reading multiple Excel files at once?

3 Ansichten (letzte 30 Tage)
I have a large number of excel files with the name of a sensor and then a time following the name: "PAR_TOP_230", "PAR_TOP_330", etc. to indicate the hour in which the sample was collected (the time always varies by one hour between samples). I was wondering if there is some way to make a loop that reads each excel file in order and extracts a single column of data from each file. I know how to use functions to import excel data, but I am unsure of how to refer to file names in a MATLAB for loop.
I was thinking something along the lines of the code below.
time=[130,230,330...];
for i= 1:length(time)
lum(:,i)=csvread('PAR_TOP_((time(i)).csv',3,2);
end

Akzeptierte Antwort

David Hill
David Hill am 21 Nov. 2022
time=[130,230,330...];
for i= 1:length(time)
lum(:,i)=csvread(sprintf('PAR_TOP_%d.csv',time(i)),3,2);
end

Weitere Antworten (0)

Kategorien

Mehr zu Data Import from MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by