Question: Instructions: Use the provided Live Script for your lab write - up . Just like for all the other lab reports, unless otherwise specified, include

Instructions: Use the provided Live Script for your lab write-up. Just like for all the other lab reports,
unless otherwise specified, include in your lab report all M-files, figures, MATLAB input commands, the
corresponding output, and the answers to the questions.
(a) Modify the function ex_(w)ith_(2)eqs to solve the IVP (4) for 0=t=50 using the MATLAB
routine ode45. Call the new function LAB04ex1.
Let t,Y (note the upper case Y ) be the output of ode45 and y and v the unknown functions.
Use the following commands to define the ODE:
function dYdt=f(t,y)
y=Y(1); v=Y(2);
dYdt=[v;8*sin(t)-8*v-7*y];
Plot y(t) and v(t) in the same window (do not use subplot), and the phase plot showing v vs
yv(t)=y^(')(t), use 'v (t)=y ''(t)'[-3.6,3.6] to adjust the y-limits for both plots. Adjust
the x-limits in the phase plot so as to reproduce the pictures in Figure 7.
Figure 7: Time series y=y(t) and v=v(t)=y^(')(t)(left), and phase plot v=y^(') vs. y for (4).
(b) By reading the matrix Y and the vector t , find (approximately) the last three values of t in
the interval 0=t=50 at which y reaches a local maximum. Note that, because the M-file
LAB04ex 1.m is a function file, all the variables are local and thus not available in the Command
Window. To read the matrix Y and the vector t , you need to modify the M -file by adding the
line t,Y(:,1),Y(:,2)y,v yt-values where the maxima occur, you should not expect v(=y^(')) to be exactly 0
at local maxima, but only close to 0 y ?
(d) Modify the initial conditions to y(0)=1.1,v(0)=1.8 and run the file LAB04ex1.m with
the modified initial conditions. Based on the new graphs, determine whether the long term
behavior of the solution changes. Explain. Include the pictures with the modified initial
conditions to support your answer.
ex_with_param
function ex_with_param
t0=0; tf =3; y0=1;
a =1;
[t,y]= ode45(@f,[t0,tf],y0,[],a);
disp(['y(' num2str(t(end))')=' num2str(y(end))])
disp(['length of y =' num2str(length(y))])
end
%-------------------------------------------------
function dydt = f(t,y,a)
dydt =-a*(y-exp(-t))-exp(-t);
end
ex_with_2eqs
t0=0; tf =20; y0=[10;60];
a =.8; b =.01; c =.6; d =.1;
[t,y]= ode45(@f,[t0,tf],y0,[],a,b,c,d);
u1= y(:,1); u2= y(:,2); % y in output has 2 columns corresponding to u1 and u2
figure(1);
subplot(2,1,1); plot(t,u1,'b-+'); ylabel('u1');
subplot(2,1,2); plot(t,u2,'ro-'); ylabel('u2');
figure(2)
plot(u1,u2); axis square; xlabel('u_1'); ylabel('u_2'); % plot the phase plot
%----------------------------------------------------------------------
function dydt = f(t,y,a,b,c,d)
u1= y(1); u2= y(2);
dydt =[ a*u1-b*u1*u2 ; -c*u2+d*u1*u2];
end
Instructions: Use the provided Live Script for

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!