Info

此问题已关闭。 请重新打开它进行编辑或回答。

how to read date and time from worksheets in a excel spreadsheet?

1 次查看(过去 30 天)
I have an excel spreadsheet with several worksheets. I would like to import data from each worksheet into matlab as a separate matrix. I think xlsread works best, but I can only do it manually i.e. A = xlsread('testfile.xls',1); B=xlsread('testfile.xls',2) etc. i tried putting it into loop as for(i=1:10); data(:,:,i)=xlsread('testfile.xls',i); using this i get an error" ??? Subscripted assignment dimension mismatch. ".
this may be because all the worksheet is not of same dimensions, how can i proceed with it? thanks in advance...

回答(2 个)

ES
ES 2013-11-21
Keep your for loop in place, and Use a cell array to get your values.
for i=1:10
data{i}=xlsread('testfile.xls',i);
end

Raju
Raju 2013-11-21
and to read date and time from the sheet1 have been successful, i ve done this
[y,date_txt] = xlsread('testfile.xls');
for j=1:n
x=date_txt{j+2,1};
x1(j,:)=x;
z(j,:)=datevec(x);
clear x
end

Community Treasure Hunt

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

Start Hunting!

Translated by