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