Question: EXERCISE 2 (d) Modify LAB04ex2.m so that it solves (L4.7) using Eulers method with N = 1000 in the interval 0 t 50 (use the

EXERCISE 2

(d) Modify LAB04ex2.m so that it solves (L4.7) using Eulers method with N = 1000 in the interval 0 t 50 (use the file euler.m from LAB 3 to implement Eulers method; do not delete the lines that implement ode45). Let [te,Ye] be the output of euler, and note that Ye is a matrix with two columns from which the Eulers approximation to y(t) must be extracted. Plot the approximation to the solution y(t) computed by ode45 (in black) and the approximation computed by euler (in red) in the same window (you do not need to plot v(t) nor the phase plot). Are the solutions identical? Comment. What happens if we increase the value of N?

PLEASE ANSWER IN MATLAB CODE.

EXERCISE 2 (d) Modify LAB04ex2.m so that it solves (L4.7) using Eulers

method with N = 1000 in the interval 0 t 50 (use

LAB04ex2.m file INCLUDES:

function LAB04ex2

t0 = 0; tf = 50;

y0 = [-1;0];

[t,Y] = ode45(@f,[t0,tf],y0,[]);

y = Y(:,1); v = Y(:,2);

figure(5);

plot(t,y,'b-+',t,v,'ro-');

legend ('y(t)','v(t)=y''(t)');

ylim([-1.5,1.5])

grid on

figure(6)

plot(y,v);

axis square;

xlabel('y'); ylabel('v');

ylim([-1.5,1.5])

grid on

end

function dYdt=f(t,Y)

y=Y(1); v=Y(2);

dYdt = [v; cos(t)-4*v*y^2-3*y];

end

2. (a) Consider the modified problem +7y2 y(0)=0.5, (0)=0.5 +5y = sin t, with (L4.7) dt2 The ODE (L4.7) is very similar to (L4.4) except for the y2 term in the left-hand side. Because of the factor y2 the ODE (L4.7) is nonlinear, while (LAA) is linear. There is however very little to change in the implementation of (L4.4) to solve (L4.7). In fact, the only thing that needs to be modified is the ODE definition Modify the function defining the ODE in LAB04ex1.m. Call the revised file LAB04ex2.m. The new function M-file should reproduce the pictures in Fig L4h. Include in your report the changes you made to LAB04ex1.m to obtain LAB04ex2.m. (b) Compare the output of Figs LAg and L4h. Describe the changes in the behavior of the solution (c) Compare the long term behavior of both problems (L4.4) and (LA.7), in particular the am- (d) Modify LAB04e2.m so that it solves (LAT) using Euler's method with N = 1000 in the in the short term plitude of oscillations interval 0 S t

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 Databases Questions!