Solve a symste of 2nd order ODE using ode45
Info
This question is closed. Reopen it to edit or answer.
Show older comments
Hello.
I have to solve the system of ODE given by the problem

I have solved first order ODE and second order ODE but I cannot seem to have any success with the system of 2nd order ODE.
Any help is appreciated.
Answers (1)
James Tursa
on 1 Mar 2018
Edited: James Tursa
on 1 Mar 2018
1st order ODE means your state vector will have 1 element.
2nd order ODE means your state vector will have 2 elements.
Two 2nd order ODE's like you have above means your state vector will have 2*2 = 4 elements.
So, just do the same thing you did for the 2nd order ODE that you solved, but here you will have 4 elements to deal with instead of just 2. E.g., make your state vector definition as follows:
y = 4x1 state vector
y(1) is defined to be y1
y(2) is defined to be y2
y(3) is defined to be y1'
y(4) is defined to be y2'
So your derivative function would be based on the following expressions
dy(1) = y1' --> y(3)
dy(2) = y2' --> y(4)
dy(3) = y1'' --> -2y1 + y2 --> -2*y(1) + y(2)
dy(4) = y2'' --> y1 - y2 --> y(1) - y(2)
And the initial values given in the problem statement mapped to our state vector definitions gives
y0 = [10; % y1(0)
15; % y2(0)
0; % y1'(0)
0] % y2'(0)
2 Comments
lesluch
on 1 Mar 2018
James Tursa
on 1 Mar 2018
Edited: James Tursa
on 1 Mar 2018
I have pretty much given you the MATLAB code. I spelled out for you the exact expressions to use for dy, and I gave the the initial condition as well. Why can't you form the 4x1 derivative function from the four dy element expressions I have given you?
dy = @(t,y) [y(3);y(4);-2*y(1)+y(2);y(1)-y(2)]
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!