Reputation: 3
I have got 30 files named Data1.xls to Data30.xls. In each file, there are two sheets I'm interested in. The first is called 'Ergebnisse' where I get the name of the second sheet, which is important to me. This sheet changes its name. My problem here is that I don't know how to tell Matlab to use the changing sheet name.
What i got so far:
liste = dir('*.xls'); % how many files in the folder
liste=struct2cell(liste);
liste=liste(1,:)';
for i=1:length(liste) % i=number of files
filename=['Data' num2str(i) '.xls'];
[num,txt,raw]=xlsread(filename,'Ergebnisse');
sheet=txt(3,1);
[num,txt,raw]=xlsread(filename,sheet);
end
The answer for sheet is 'T4_quer_3' which I would normally write into the next xlsread
but it doesn't work.
Thanks for your help
Upvotes: 0
Views: 157
Reputation: 2343
you dont need the cell txt(3,1), but its content. so either go for
sheet=txt{3,1};%notice the other brackets
or you go for
[num,txt,raw]=xlsread(filename,sheet{:}); %{:}content of a cell
Upvotes: 1