From: sr on 12 Jul 2010 15:21 Hi Friends, I have a matrix B of dimension (81x1541) and i'm adding +/-5% vertical perturbation to it as follows. a=1.05; b=0.95; C = [a*B(:,1:40),b*B(:,41:80),a*B(:,81:120),b*B(:,121:160),a*B(:,161:200),b*B(:,201:240),... a*B(:,241:280),b*B(:,281:320),a*B(:,321:360),b*B(:,361:400),a*B(:,401:440),... b*B(:,441:480),a*B(:,481:520),b*B(:,521:560),a*B(:,561:600),b*B(:,601:640),a*B(:,641:680),... b*B(:,681:720),a*B(:,721:760),b*B(:,761:800),a*B(:,801:840),b*B(:,841:880),a*B(:,881:920),... b*B(:,921:960),a*B(:,961:1000),b*B(:,1001:1040),a*B(:,1041:1080),b*B(:,1081:1120),... a*B(:,1121:1160),b*B(:,1161:1200),a*B(:,1201:1240),b*B(:,1241:1280),a*B(:,1281:1320),... b*B(:,1321:1360),a*B(:,1361:1400),b*B(:,1401:1440),a*B(:,1441:1480),b*B(:,1481:1520),... a*B(:,1521:1541)]; % perturbed model +/-5% perturbation added to every 40 columns except in the end where i have only 20 columns left. Is there a way to simplify this code using for loop or any other? Thank you very much in anticipation cheers
From: dpb on 12 Jul 2010 15:29 sr wrote: .... > I have a matrix B of dimension (81x1541) and i'm adding +/-5% vertical > perturbation to it as follows. > a=1.05; > b=0.95; > C = > [a*B(:,1:40),b*B(:,41:80),... .... > +/-5% perturbation added to every 40 columns except in the end where i > have only 20 columns left. .... sure... :) How many sets of 40 columns are there in the matrix B first? doc floor % and friends may be of interest here. Then, how many row are left over? doc mod How might one then loop that many times and compute the start/end columns of the subsection to operate over on each pass? Don't forget that last pesky group of leftovers, of course. --
|
Pages: 1 Prev: Skip lines in an array -sorry Next: fit an ellipse over an object... |