In Exercise we will deal with the differential equation y′ = −2y + 2 cos t sin 2t. In preparation create the function M-file

and save the file as steady.m.
MATLAB’s solvers are able to handle multiple initial conditions for single first order equations. To do so we fake ode45 into assuming that we are solving a system consisting of the same equation repeated for each initial condition. For this purpose it is only necessary to make the function ODE file array smart, as we have for steady.m.
a) To solve the equation y′ = -2y + 2 cos t sin 2t, for initial conditions y(0) = -5, y(0) = -4, …, y(0) = 5, enter the code [t, y] = ode45(@steady, [0,30], -5:5);.
b) Graph the solutions with plot(t,y) and note that each solution approaches a periodic steady-state solution.
c) Repeat parts a) and b) with time spans [0, 10] and [0, 2π] to get a closer look at the convergence to the steady-state solution.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.