11.12: Solving Differential Equations in Simulink

Fundamentals of MATLAB Programming · LibreTexts

0%

Contents

    Text

    Size
    100%
    Theme
    Typeface
    Line length
    Spacing

    Read aloud

    How

    Speed: 1×
    Light up
    Highlight

    Symbols: Mulberry Symbols, © 2018–2026 Steve Lee, CC BY-SA 4.0 (licence, the set), the site's own copies.

    From LibreTexts, under CC BY-NC-SA, as the source states it; its equations are written in TeX, which the PDF shows typeset. This page at LibreTexts.

    11.12: Solving Differential Equations in Simulink

    One of the strongest reasons to learn Simulink is that it is very useful for solving differential equations. Differential equations describe relationships involving rates of change. In engineering, rates of change appear everywhere: velocity is the rate of change of position, acceleration is the rate of change of velocity, current can depend on changing voltage, and temperature can change over time.

    A simple differential equation has the form:

    dx/dt = sin(t)

    This equation says that the rate of change of x with respect to time is equal to sin(t). To find x, we integrate sin(t) with respect to time. In Simulink, the Integrator block performs this integration.

    Note

    If you can write an equation in the form derivative = something, then you can often build a Simulink model by feeding that something into an Integrator block. The output of the Integrator is the original variable.

    Example: Solving dx/dt = sin(t)

    For this model, the input to the Integrator is sin(t), and the output of the Integrator is x(t).

    Blocks needed:

    • Sine Wave block from Sources
    • Integrator block from Continuous or Commonly Used Blocks
    • Scope block from Sinks

    Build the model in Simulink:

    1. Drag a Sine Wave block into the model.

    2. Drag an Integrator block into the model.

    3. Connect the Sine Wave output to the Integrator input.

    4. Connect the Integrator output to a Scope block.

    5. Connect the Sine block to the same Scope block.

    6. Open the Sine Wave block and set the amplitude to 1 and the frequency to 1.

    7. Open the Integrator block and set the initial condition to 0.

    8. Change the stop Time to 2*pi.

    9. Run the model.

    clipboard_e2ad94358801ca562463617c4d47c0c66.png

    The initial condition tells Simulink the starting value of x. Without an initial condition, a differential equation usually does not have a unique solution.

    After running the model, double-click the Scope block to see the result. There should be two curves: one for sin(t) and one for x(t). Add a legend to identify the two curves.

    1. Open the Scope graph.
    2. Go to Scope → Settings
    3. Check the box next to Legend.

    After running the model, double click the Scope block to see the result. There will be two curves, one sin(t) and the other x(t). Add a legend to identify the two curves.

    clipboard_e318320de1157466ba02e1e85b07b0d91.png

    The blue curve represents the input signal, sin(t), and the yellow curve represents the integral solution, x(t).

    clipboard_eb8b830c4765871d86dfc70beff226612.png


    This page titled 11.12: Solving Differential Equations in Simulink was last modified on Tue, 30 Jun 2026 02:11:50 GMT and is shared under a CC BY-NC-SA license and was authored, remixed, and/or curated by Zara Noroozi.