Search code examples
matlabsimulinkequationodedifferential-equations

solve second order ODE in MATLAB/SIMULINK


I don't know how to solve this second order ODE in SIMULINK:

enter image description here

I rewrote it to the system of first order ODEs:

enter image description here

then

enter image description here

giving

enter image description here

My SIMULINK blocks are here:

SIMULINK blocks

giving this Scope:

enter image description here

This is the plot of symbolic solution from dsolve:

enter image description here

It looks like the functions (plots) from symbolic and SIMULINK are little similar.


Solution

  • The solution was found by Phil Goddard. His answer in comments:

    In Simulink you are plotting y_dot, while the symbolic solution is a plot of y.

    So the problem was that Scope was plotting the y'. The correct position of Scope is here:

    enter image description here

    giving the correct plot of y:

    enter image description here

    as you can see in the plot of symbolic solution:

    enter image description here