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

6 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

David Hill
David Hill il 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

Più risposte (0)

Categorie

Scopri di più su Data Import from MATLAB in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by