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

6 ビュー (過去 30 日間)
Morgan Illman
Morgan Illman 2022 年 11 月 21 日
コメント済み: Morgan Illman 2022 年 11 月 21 日
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

採用された回答

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by