Matlab Question Objective Solve an IVP using the Laplace tra
Matlab Question: Objective: Solve an IVP using the Laplace transform Define g(t) = 3 if 0 < t < 2 g(t) = t+1 if 2 < t < 5 g(t) = 5 if t > 5 Solve the IVP y\'\'+2y\'+5y=g(t) y(0)=2 and y\'(0)=1
The following is my code but the ezplot(y, [0,12]) part gives me an error for saying ilaplace can\'t deal with double type.
Can someone help me fix this?
objective: solve an IV using the Laplace transform Details Define g(t) 3 if 0 t 2 g(t) if t+1 2 t 5 g(t) 5 if t 5 Solve the IVP 2y \'+5y g (t) (0) 2 and y\' (0) 1| Plot the solution for ItI in II0, 12] I and Iyl in II0,2.25] I. (in your answer, explain your steps using comments). syms g y(t) t Y G g (t 3*( 1-heaviside (t-2))+(t+1)*(heaviside t-2)-heaviside (t-5))+5* (heaviside (t-5 G-laplace (g) 0DE diff (y(t) t,2)+2*diff(y (t),t,1)+5*y (t) LODE laplace (ODE)-G %calculate laplace transform L ODE-subs (L 0DE y (0) ,2) L ODE subs (L 0DE D (y) (0 ,1) LODE subs (L_0DE, laplace (y(t), t s) Y) %factor out the y(t) Y solve LODE,Y) y- laplace (Y) ez plot (y, [0,12])Solution
In order to avoid \"Undefined function \'ilaplace\' for input arguments of type \'double\'.\", Try including the below in your code:
ezplot(y,[0,12])
title(\'Plot of IVP\')
ezplot(g(t),[0,12])
OR, try using ytrans = solve(L_ODE,Y) instead of y = solve(L_ODE,Y)
