I have drawn the graph of nonlinear pendulum’s equation. I needalso in the same plot the graph of the linear pendulum’s equationto see the difference. Use matlab
the following code is for the nonlinear case
clear; clc;
L = 2; g=32.17;
F=@(t,Y) [ Y(2) ; …
-(g/L)*sin(Y(1))];
t0=0; tf=2; n=1000; h=(tf-t0)/n;
alpha = [ pi/6 ; 0 ];
[t,w] = midpoint(t0,h,n,alpha,F);
[t’,w’]
plot(t,w(1,:));grid on
function [t,w] = midpoint(t0,h,n,alpha,F)
w(1:2,1)=alpha; t(1)=t0;
for i=1:n
K1 = F(t(i),w(1:2, i));
K2 = F(t(i)+0.5*h,w(1:2, i)+0.5*h*K1);
w(1:2, i+1)=w(1:2, i)+(K2)*h;
t(i+1)=t(i)+h;
end
end
Expert Answer
An answer will be send to you shortly. . . . .