Search code examples
matlabsimulinksolverodedifferential-equations

Solving ODE with Simulink in Matlab


I need to solve this ODE using Simulink and I don't know how to make it. I only know how to do it using ODE solvers.

y'' - y' - 2y = e^(3x)

y(0)=1, y'(0)=2.

I rewrote the equation obtaining an ODEs:

y' = f(x,y)

y(x0) = y0

y'1 = y2

y2= e^(3*x) + y' + 2y 

Using ODE solver.

If someone can help me to solve this using a Simulink Model I would appreciate it.

I know how to solve it in Matlab using ODE solvers as ode23 and ode23s but I don't know how to do it using a Simulink Model.

Thanks in advance


Solution

  • Can you solve it in closed form? Looks doable to me. I advise anyone to have the answer in hand if possible before you start a numerical solution.

    Here's what I get. Check me:

    y(x) = e^(-x)*(8e^3x + 3e^4x + 1)/12
    

    Wolfram Alpha says this is correct.

    (Note: Trouble for large values of x - this response will grow at e^3x rate.)

    You need to express this as a set of coupled first order ODEs.

    y' = z
    
    z' = z + 2y + e^(3x)
    

    Boundary conditions become:

    y(0) = 1
    z(0) = 2