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
0 个评论
采纳的回答
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
2018-8-29
- Your filename needs an extension --> cyclist_data.xlsx
- 'sheets{sheetNo}' is not how you use the variable sheets. Just look at how I used it in my example!
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!