Lab 6 - - MAT 275 Lab
Forced Equations and Resonance
Exercise 1
Part (a)
Period of the forced oscillation:
Numerical value of the angle : 2.3680 rad= .
Part (b)
type LAB06ex1_b.m
clear all; %this deletes all variables
omega0 = 2; c = 1; omega = 2.6;
param = [omega0,c,omega];
t0 = 0; y0 = 0; v0 = 0; Y0 = [y0;v0]; tf = 60;
options = odeset('AbsTol',1e-10,'relTol',1e-10);
[t,Y] = ode45(@f,[t0,tf],Y0,options,param);
y = Y(:,1); v = Y(:,2);
figure(1)
plot(t,y,'b-'); ylabel('y'); grid on; xlabel('t');
t1 = 25; i = find(t>t1);
C = (max(Y(i,1))-min(Y(i,1)))/2;
disp(['computed amplitude of forced oscillation = ', num2str(C)]);
Ctheory = 1/sqrt((omega0^2-omega^2)^2+(c*omega)^2);
disp(['theoretical amplitude = ', num2str(Ctheory)]);
if (omega0 > omega)
alpha=atan(c*omega/(omega0^2-omega^2));
else
alpha=(pi+atan(c*omega/(omega0^2-omega^2)));
end
yc=y-Ctheory*cos(omega*t-alpha);
figure(2)
plot(t,yc,'b-');ylabel('yc');xlabel('t');grid on;
title('complementary solution');
%----------------------------------------------------------------
function dYdt = f(t,Y,param)
y = Y(1); v = Y(2);
omega0 = param(1); c = param(2); omega = param(3);