MATLAB HELP! = 25 ; (max(Y(1,1))-min(Y(1,1)))/2; 10 t1 1-11nd (t>t 1) ; 11 C = 1
ID: 3866569 • Letter: M
Question
MATLAB HELP!
= 25 ; (max(Y(1,1))-min(Y(1,1)))/2; 10 t1 1-11nd (t>t 1) ; 11 C = 12 disp([' computed amplitude of forced oscillation num2atr(C)] 13 Ctheory -1/sqrt ((omega0 2-onega 2) -2+(c omega) -2); 14 disp(['theoretical amplitudenum2str (Ctheory)]) 15 % 16 function dYdt -f(t,Y,param) 17 y-Y(1): v = Y(2); 18 omega0-param(1) cparam(2); omega param (3) When executing this program we get computed amplitude of forced oscillation = 0.24801 theoretical amplitude = 0.24801 Lines 10-14 deserve some explanation. Line 10 defines a time tl after which we think the contribution of the first term in (L6.2) has become negligible compared to the second term. This depends of course on the parameter values, in particular c, with c = 1 we obtain e- ~ 3.7 x 10-6 for t = 25, so this is certainly small enough compared to the amplitude seen on Figure L6a. The index i of time values larger than tl is then determined. The quantity Y(1,1) refers to the values of y associated to times larger than ti only. The computed amplitude is simply half the difference between the max and the min values. This value is compared to the theoretical valu (L6.3 Figure L6a: Forced oscillation 1. (a) What is the period of the forced oscillation? What is the numerical value (modulo 2) of the angle a defined by (L6.4)? (b) In this question you are asked to modify the file LAB06ex1.m in order to plot the complm tary solution of (L6.1), that is, the first tern in (L6.2). First define in the file the angle a (alpha) using (L6.4), then evaluate the complementary solution yc by subtracting thequ tity Coos(t - a) from the numerical solution y. Plot the resulting quantity. Does it look like an exponentially decreasing oscillation? Why or why not? Include the modified M-fileExplanation / Answer
function LAB06ex1 clc omega0 = 3; c = 1; omega = 2.4; param = [omega0,c,omega]; t0 = 0; y0 = 0; v0 = 0; Y0 = [y0;v0]; tf = 50; 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; 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)]); %---------------------------------------------------------------- function dYdt = f(t,Y,param) y = Y(1); v = Y(2); omega0 = param(1); c = param(2); omega = param(3); dYdt = [ v ; cos(omega*t)-omega0^2*y-c*v ];
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.