For loop for read xls

1 回表示 (過去 30 日間)
Daeeun Bae
Daeeun Bae 2022 年 7 月 3 日
回答済み: KSSV 2022 年 7 月 3 日
Hello. I have a set of data and the names of the files are as follows.
WIOT95_ROW_Apr12, WIOT96_ROW_Apr12, ... ,WIOT11_ROW_Apr12.
I would like to use for loop to read the file sequentially and create some variables for each year.
I used the following code and it didn't work.
for j = 95:99
raw(j) = readtable('WIOT(j)_ROW_Apr12','Sheet','WIOT_19(j)','Range','E7:BCI1441');
wiot(j) = table2array(raw(j));
end
I was wondering how I can create the codes to do this work.
Thank you.

回答 (1 件)

KSSV
KSSV 2022 年 7 月 3 日
xlFiles = dir('*.xls') ; % give extension of your files
N = length(xlFiles) ;
% loop for each file
for i = 1:N
xlFile = XlFiles(i).name ;
T = readtable(xlFile) ;
% Do what you want
end

カテゴリ

Help Center および File ExchangeDebugging and Analysis についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by