A question about a for loop
Info
This question is closed. Reopen it to edit or answer.
Show older comments
I have a excel file with a 5000x7 matrix.
I would like to build a for loop which makes sets of 60x7.
The way I tried to achieve this is through the following script:
Data=xlsread('bootstrap.xls','blad1','A1:G4740');
mv_laag=[0.13 0.62 0.03 0 0.00 0 0.23];
for i=1:60
for j=1:7
set1(i,1)=(Data(i,1)*mv_laag(1))+(Data(i,2)*mv_laag(2))+Data(i,3)*mv_laag(3)+Data(i,4)*mv_laag(4)+Data(i,5)*mv_laag(5)+Data(i,6)*mv_laag(6)+Data(i,7)*...
mv_laag(7)
end
end
for i=60:120
for j=1:7
set2(i,1)=(Data(i,1)*mv_laag(1))+(Data(i,2)*mv_laag(2))+Data(i,3)*mv_laag(3)+Data(i,4)*mv_laag(4)+Data(i,5)*mv_laag(5)+Data(i,6)*mv_laag(6)+Data(i,7)*...
mv_laag(7)
end
end
But ofcourse, when trying the latter, it doesn't work.Since it just grabs i=1:120 :(
Any help?
Answers (1)
Andrei Bobrov
on 2 Aug 2012
Edited: Andrei Bobrov
on 2 Aug 2012
Data=xlsread('bootstrap.xls','blad1','A1:G4740');
mv_laag=[0.13 0.62 0.03 0 0.00 0 0.23]';
d = Data*mv_laag;
out = reshape([d;nan(rem(numel(d),60),1)],60,[]);
or
Data = cell2mat(cellfun(@(x)xlsread('bootstrap.xls','blad1',x),...
{'A1:C4740','G1:G4740'},'un',0));
mv_laag=[0.13 0.62 0.03 0.23]';
d = Data*mv_laag;
out = reshape([d;nan(rem(numel(d),60),1)],60,[]);
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!