Skip to content
Permalink
master
Go to file
 
 
Cannot retrieve contributors at this time
22 lines (21 sloc) 517 Bytes
function y=Prob2ptC(ode,dt,y0,tlimits)
maxit=100;
t=[tlimits(1):dt:tlimits(2)];
y=zeros(length(t),1);
y(1)=y0;
for i=2:length(t)
dy=ode(t(i-1),y(i-1));
y(i)=y(i-1)+dt*dy;
dyc=(dy+ode(t(i),y(i)))/2;
y(i)=y(i-1)+dt*dyc;
nits=1;
while(1)
nits=nits+1;
yold=y(i);
dyc=(dy+ode(t(i),y(i)))/2;
y(i)=y(i-1)+dt*dyc;
ea=abs(yold-y(i))/y(i)*100;
if ea<.0001|nits>maxit;break;end;
end;
end
end
You can’t perform that action at this time.