I have data in the same excel workbook but in 10 different work sheets and i'm trying to run a loop that will read in the data from each work sheet consectutively.

조회 수: 2 (최근 30일)
this is how i've tried to do it so far and i'm not sure how to get it to work
for ii=01:10
data(ii)=xlsread('workbook.xlsx','worksheet(ii)','B10:F370');
end

채택된 답변

KL
KL 2018년 8월 29일
You could use xlsread along with xlsinfo.
[status,sheets] = xlsfinfo(filename);
Now, you have all the sheet names under sheets and you loop through that.
data = cell(numel(sheet),1); %pre-allocate your variable
for sheetNo = 1:numel(sheet)
data(sheetNo,1) = xlsread(filename,sheets{sheetNo},Range);
...
end
Goodluck!
  댓글 수: 3
KL
KL 2018년 8월 29일
  1. Your filename needs an extension --> cyclist_data.xlsx
  2. 'sheets{sheetNo}' is not how you use the variable sheets. Just look at how I used it in my example!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by