11.10: Modeling y = sin(x)/x

Fundamentals of MATLAB Programming · LibreTexts

0%

Contents

    Text

    Size
    100%
    Theme
    Typeface
    Line length
    Spacing

    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.10: Modeling y = sin(x)/x

    The next example uses a Ramp block to generate changing x values, then computes:

    y = sin(x) / x

    This function is useful as a practice example because it requires a source signal, a sine operation, a divide operation, and a scope.

    Blocks needed:

    • Ramp block from Sources
    • Trigonometric Function block or Math Function block set to sin
    • Divide block from Math Operations
    • Scope block

    Build the model:

    1. Drag a Ramp block into the model to generate x values.

    2. Set the Ramp block initial output to -5 for a graph from approximately -5 to 5, or use -20 for a wider view.

    3. Send the Ramp output to a sine block to compute sin(x).

    4. Also send the Ramp output directly to the denominator input of the Divide block.

    5. Connect the sine output to the numerator input of the Divide block.

    6. Connect the Divide block output to a Scope block.

    7. Run the model.

    Setting up the model:

    clipboard_ecdb31bc0ff2422ecbffed2fdc5388884.png

    The Scope output:

    clipboard_eb95f7cce22854fc14f78184b9686732b.png

    If the graph looks jagged, the simulation may be using steps that are too large. You can make the plotted result smoother by changing the solver maximum step size.

    1. Go to Modeling > Model Settings.

    2. Choose Solver.

    3. Under Solver details, set Max step size to a smaller value such as 0.01.

    4. Run the model again.

    clipboard_e6cd9cbc8e15b7cb47086442ec09f9375.png

    Caution

    A note about x = 0
    The expression sin(x)/x has a removable discontinuity at x = 0. Mathematically, the limit as x approaches 0 is 1. Depending on the exact solver steps and block setup, a model may behave differently near zero. This is a good reminder that models require both mathematical understanding and careful simulation settings.


    This page titled 11.10: Modeling y = sin(x)/x 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.