Permalink
Cannot retrieve contributors at this time
06_initial_value_ode/prob4plot.m
Go to fileset(0, 'defaultAxesFontSize', 16) | |
set(0,'defaultTextFontSize',14) | |
set(0,'defaultLineLineWidth',3) | |
cd = 0.25; | |
m = 60; | |
g = 9.81; | |
dt = 0.1; | |
t = [0:dt:12]'; | |
x = zeros(length(t),2); | |
x(1,:) = [1000, 0]; | |
for i = 2:length(t) | |
dx = prob4_ode(t,x(i-1,:)); | |
x(i,:) = x(i-1,:)+dt*dx; | |
end | |
c = figure(3); | |
x_heun = prob4ptC (@(t,x) prob4_ode(t,x), 0.1, [1000, 0], [0 12]); | |
plot(t, m/cd*log(cosh(sqrt((g*cd)/m)*t))+1000,t,x(:,1),t,x_heun(:,1)); | |
legend('Analytical','Euler','Heuns','Location','Northeast') | |
xlabel('Time') | |
ylabel('Position') |