Using xlsread in a for loop

I have this code:
filename = 'C:\PATH\variable_analysis.xlsx';
A= xlsread(filename,'0.600');
But I want to read in 20 worksheets (0.601, 0.602, ... 0.620) Can I do this in a for loop and create a struct that contains the matrix from each worksheet?

回答 (1 件)

Rik
Rik 2018 年 11 月 10 日

1 投票

If the worksheet names are 0.600 etc you can use the code below.
B=struct;
for n=20:-1:1
A= xlsread(filename,sprintf('0.6%02d',n));
B(n).data=A;
end

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2018 年 11 月 9 日

回答済み:

Rik
2018 年 11 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by