How to read multiple excel tabs each as a separate matrix
이전 댓글 표시
Dear All,
I am given the task to find the maximum value within each tab of a number of excel files. I used xlsread only to find out that it took a day (25 hours) to read an excel file with 6600 tabs. These are my codes. Is there other ways to get this done faster?
myFolder = 'D:\study';
filePattern = fullfile(myFolder, '*.xlsx'); excelFiles = dir(filePattern); for k = 1:length(excelFiles) baseFileName = excelFiles(k).name; fullFileName = fullfile(myFolder, baseFileName); fprintf(1, 'Now reading %s\n', fullFileName);
[type,sheetname] = xlsfinfo(fullFileName);
m=size(sheetname,2);
for i=5:m
Sheet = char(sheetname(1,i)) ;
alldata = xlsread(fullFileName, Sheet);
[x,y]=max(alldata(:,2));
output(i,:)=alldata(y,:);
end
Warm regards, Hallis
채택된 답변
추가 답변 (1개)
Fangjun Jiang
2012년 12월 5일
0 개 추천
xlsread() has a lot if overhead. Follow this link to use Excel COM method.
댓글 수: 3
abdulhallis aziz
2012년 12월 7일
편집: Fangjun Jiang
2012년 12월 7일
Fangjun Jiang
2012년 12월 7일
It is an error about using cell2mat(). It requires all the data to be the same data type. You can't have a mix of e.g. numerical and string data.
hime skuld
2015년 12월 20일
Why I cannot run this code properly. It looks like it cannot read my sheet in excel. after run, I found my N_file = 0 . I`m using matlab R2015b and excel 2013. somebody can tell me whats the problem.
카테고리
도움말 센터 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!