Reputation: 59
I try to process data from an excel file from several sheets (~200). Luckily the data is always at the same position in each sheet. I wrote the following code for this purpose which unfortunately does not work since I have problems with converting the cell entries to a matrix. Any idea how to solve that? Thanks!
[~, sheet_name] = xlsfinfo('mydata.xlsx');
for k=1:numel(sheet_name)
data{k}=xlsread('mydata.xlsx',sheet_name{k},'A7:A14');
b{k}=cell2mat(data{k}) %this line does not work...
end```
Upvotes: 0
Views: 141
Reputation: 75
You are not using the cell2mat command on the whole cell.
data{k}
will already give you a matrix that contains the 7 entries of the sheet k.
You either need to use cell2mat on the whole cell after the loop:
b=cell2mat(data)
or
b(k)=data{k}
within the loop.
Upvotes: 0