Personal Website:
Scott Congreve

Teaching

Download<< Back

function compare_eul

[t,x]=ode23(@popgrowth, [0,3], 1);
plot(t,x,'-k','DisplayName','ode23');
axis([0 3 0 8]);
hold on;

title('euler');
xlabel('time');
ylabel('x');
[t,x]=eul(@popgrowth, 0, 3, 1, 1/2); plot(t,x,'-ro','DisplayName','Euler (h=1/2)');
[t,x]=eul(@popgrowth, 0, 3, 1, 1/4); plot(t,x,'-bx','DisplayName','Euler (h=1/4)');
[t,x]=eul(@popgrowth, 0, 3, 1, 1/8); plot(t,x,'-m+','DisplayName','Euler (h=1/8)');
legend('Location','NorthWest','FontSize',18);