Vous êtes sur la page 1sur 4

Question 1

m= 2;
M=5;
H0=5;
k=125;
Wn= sqrt(k/M);
g=9.81;
t0= sqrt(2*H0/g);
T1= linspace(0,t0,100);
H1= H0-((g/2).*T1.^2)
plot(T1,H1,'b','linewidth',2)
hold on
grid on
xlabel('time')
ylabel('response')
Vm=6.60;
VM= 1.32;
Y0=0;
Tn= (2*pi/Wn);
F=@(t)Y0-((Vm.*t)-(g/2).*t.^2)-((VM/Wn).*sin(Wn.*t));
tI=fsolve(F,0.5*Tn)
tI2=tI
T2= linspace(t0,tI+t0,60);
H2=(Vm.*(T2-t0)-(g/2).*(T2-t0).^2);
plot(T2,H2,'r+','linewidth',2)
hold on;
T3=linspace(t0,tI+t0,100);
H3=(-VM/Wn).*sin(Wn.*(T3-t0));
plot(T3,H3,'go','linewidth',1)

Question 2(a)
function myoutput=Linearfunction(Time,Linear)
g=9.81; L=2;
myoutput=[Linear(2);-(g/L)*(Linear(1))]
function myoutput=NonLinearfunction(time,Non_Linear)
g=9.81; L=2;
myoutput=[Non_Linear(2);-(g/L)*sin(Non_Linear(1))]

% Non linear Plot


time_span=[0 20]; % Range of Time
initial_Angle=[pi/18,0]; % Inputting Intial Displacement and Angular
Velocity
[time,Non_Linear]=ode45(@NonLinearfunction,time_span,initial_Angle)
% Linear Plot
[Time,Linear]=ode45(@Linearfunction,time_span,initial_Angle);
plot(time,Non_Linear(:,1),'r--','Linewidth',2)
grid on
hold on
plot(Time,Linear(:,1),'b','Linewidth',1)
legend('\bfNon-linear','Linear')
xlabel('\bftime(sec)')
ylabel('\bfDisplacement')
title('\bfComparison of Linear and Nonlinear at theta = 10 deg')

Question 2(b)

function myoutput=Linearfunction(Time,Linear)
g=9.81; L=2;
myoutput=[Linear(2);-(g/L)*(Linear(1))]
function myoutput=NonLinearfunction(time,Non_Linear)
g=9.81; L=2;
myoutput=[Non_Linear(2);-(g/L)*sin(Non_Linear(1))]

% Non linear
time_span=[0 20]; % Range of Time
initial_Angle=[pi/3,0]; % Inputting Intial Displacement and Angular
Velocity
[time,Non_Linear]=ode45(@NonLinearfunction,time_span,initial_Angle)
% Linear
[Time,Linear]=ode45(@Linearfunction,time_span,initial_Angle);
plot(time,Non_Linear(:,1),'r--','Linewidth',2)
grid on
hold on
plot(Time,Linear(:,1),'b','Linewidth',1)
legend('\bfNon-linear','Linear')
xlabel('\bftime(sec)')
ylabel('\bfDisplacement')
title('\bfComparison of Linear and Nonlinear at theta = 60 deg')

Question(4)
L=2;

g=9.81;
Theta0=linspace(pi/18,(4*pi)/9,60);

TLin=2*pi*sqrt(L/g) % for Linear pendulum

Time_Nonlin=(2*pi*sqrt(L/g))*(1+(1/16)*(Theta0.^2)+(11/3072)*(Theta0.^4))
% for Non linear Pendulum

%
plotting
plot(Theta0,TLin,'g+','linewidth',3)
hold on
plot(Theta0,Time_Nonlin,'b-','linewidth',3)
xlabel('\bfTime Period')
ylabel('\bfInitial Angle')
title('\bf Initial angle vs Natural Period')