Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.


Ghulaam
Posts:
1
Registered:
3/8/14


Speed up
Posted:
Mar 8, 2014 11:04 AM


Hi would appreciate some assistance in speeding up the following code via vectorisation
for h = 0.9:0.05:1.8 for iv = 0.2:0.1:2 y(1)=iv; for k = 2:520 y(k) = y(k1)+h*(y(k1)+0.5*h*y(k1)*(1y(k1)))*(1y(k1)0.5*h*y(k1)*(1y(k1))); end plot(h*(ones(20,1)), y(501:520),'*'), set(gca(),"auto_clear","off") end end
title('Modified Euler') xlabel('h'), ylabel('last 20 y')
set(gca(),"grid",[1 1]), set(gca(),"auto_clear","on")



