Using xlsread in a for loop

조회 수: 3 (최근 30일)
Benjamin
Benjamin 2018년 11월 9일
답변: Rik 2018년 11월 10일
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일
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

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by