From: Stefan on 23 Jul 2010 15:10 for x1 = -10:0.1:10; for x2 = -10:0.1:10; for x3 = -10:0.1:10; for x4 = -10:0.1:10; V =[x1;x2]'*A*[x1;x2] + [x1;x2]'*expm(B)*[x3;x4] end end end end
From: Stefan on 23 Jul 2010 15:18 Hi, Can someone help me to make this piece of code more efficient? Thanks "Stefan " <aidematlab(a)yahoo.ca> wrote in message <i2cpf0$j3k$1(a)fred.mathworks.com>... > > for x1 = -10:0.1:10; > for x2 = -10:0.1:10; > for x3 = -10:0.1:10; > for x4 = -10:0.1:10; > > V =[x1;x2]'*A*[x1;x2] + [x1;x2]'*expm(B)*[x3;x4] > end > end > end > end
From: Stefan on 23 Jul 2010 15:21 Hi, Can someone help me to make this piece of code more efficient? Thanks Here A =[1 2;2;1]; B = [4 2;2;5]; "Stefan " <aidematlab(a)yahoo.ca> wrote in message <i2cpf0$j3k$1(a)fred.mathworks.com>... > > for x1 = -10:0.1:10; > for x2 = -10:0.1:10; > for x3 = -10:0.1:10; > for x4 = -10:0.1:10; > > V =[x1;x2]'*A*[x1;x2] + [x1;x2]'*expm(B)*[x3;x4] > end > end > end > end
From: Walter Roberson on 23 Jul 2010 15:21 Stefan wrote: > > for x1 = -10:0.1:10; Before this statement we already had enough information to calculate expm(B) > for x2 = -10:0.1:10; After that statement we have enough information to calculate [x1;x2]'*A*[x1;x2] > for x3 = -10:0.1:10; > for x4 = -10:0.1:10; > V =[x1;x2]'*A*[x1;x2] + [x1;x2]'*expm(B)*[x3;x4] No need to do all those calculations here: as indicated above some of this can be pre-calculated. > end > end > end > end After using the above hints, you might find ways to vectorize more of the calculations.
From: Roger Stafford on 23 Jul 2010 15:32
"Stefan " <aidematlab(a)yahoo.ca> wrote in message <i2cpf0$j3k$1(a)fred.mathworks.com>... > > for x1 = -10:0.1:10; > for x2 = -10:0.1:10; > for x3 = -10:0.1:10; > for x4 = -10:0.1:10; > > V =[x1;x2]'*A*[x1;x2] + [x1;x2]'*expm(B)*[x3;x4] > end > end > end > end - - - - - - - - - What is it you wish to do with those 1,632,240,801 V's after you have computed them? Roger Stafford |