Personal Website:
Scott Congreve

Teaching

Download << Back OutputCode

%% Question 4

%% $x_0 = (-1.5, 0)^\top$
[t,x] = ode23(@pendulum, [0,6*pi], [-1.5, 0]);
figure;
plot(t,x(:,1),'DisplayName','x');
hold on;
plot(t,x(:,2),'DisplayName','x''');
xlabel('t');
legend('Location','SouthEast');

%% $x_0 = (-3, 0)^\top$
[t,x] = ode23(@pendulum, [0,6*pi], [-3, 0]);
figure;
plot(t,x(:,1),'DisplayName','x');
hold on;
plot(t,x(:,2),'DisplayName','x''');
xlabel('t');
legend('Location','SouthEast');

%% $x_0 = (-\pi, 0)^\top$
[t,x] = ode23(@pendulum, [0,6*pi], [-pi, 0]);
figure;
plot(t,x(:,1),'DisplayName','x');
hold on;
plot(t,x(:,2),'DisplayName','x''');
xlabel('t');
legend('Location','SouthEast');