Skip to content
Permalink
master
Go to file
 
 
Cannot retrieve contributors at this time
17 lines (17 sloc) 427 Bytes
set(0, 'defaultAxesFontSize', 16)
set(0,'defaultTextFontSize',14)
set(0,'defaultLineLineWidth',3)
dt = 0.1;
t = [0:dt:3];
y = zeros(size(t));
y(1) = 1;
for i = 2:length(t)
dy = prob2_ode(t,y(i-1));
y(i) = y(i-1)+dt*dy;
end
a = figure(1);
y_heun = Prob2ptC (@(t,y) prob2_ode(t,y), 0.1, 1, [0 3]);
plot(t,exp(-t),t,y,t,y_heun);
legend('Analytical','Euler','Heun','Location','Northeast')
xlabel('Time')
ylabel('Position')
You can’t perform that action at this time.