Hi Jhryssa,
Here is how you can solve the given ODE.
Convert the second-order ODE into a system of first-order ODEs: MATLAB's ode45 solver is designed for systems of first-order ODEs, so you will need to rewrite the second-order ODE into a system of two first-order equations.
The given ODE is: ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1770060/image.png)
with the initial conditions
and ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1770070/image.png)
Introduce new variables: Let
. Then, the system of first-order equations becomes: Set up initial conditions: From the problem,
and
. Here is the MATLAB implementaion:
function dydt = ode_system(t, y)
dydt(2) = (2*y(1) - t^2*y(2)) / t;
[t, y] = ode45(@ode_system, tspan, y0);
title('Solution of the ODE')
Please refer to the documentation link to learn more about ode45.
Hope this helps!