11.6: Subtracting Two Numbers

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.6: Subtracting Two Numbers

    The Sum block can also subtract. This may feel a little surprising at first because the block is called Sum, but the block can be configured to add or subtract each input.

    Double-click the Sum block. In the List of signs field, change the signs from:

    ++
    
    

    to:

    +-
    
    

    clipboard_ec7c93c458209cbe7374a29dc0ec8aa67.png

    Now the first input is added and the second input is subtracted. If the two Constant blocks contain 5 and 3, the output becomes:

    5 - 3 = 2
    
    

    clipboard_e6dda080c4223b0ff0514fb0e398a5c88.png

    You can also create a Sum block with more than two inputs. For example, a List of signs such as +++ creates three input ports that are all added. A List of signs such as ++- creates three input ports where the first two are added and the third is subtracted.


    This page titled 11.6: Subtracting Two Numbers was last modified on Tue, 30 Jun 2026 02:11:49 GMT and is shared under a CC BY-NC-SA license and was authored, remixed, and/or curated by Zara Noroozi.