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

6 vues (au cours des 30 derniers jours)
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

Réponse acceptée

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

Plus de réponses (0)

Catégories

En savoir plus sur Data Import from MATLAB dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by