Skip to main content

2.12) Order Of Calculations


    The last examples highlighted the importance of the order in which Matlab solves commands. The standard order of evaluation for arithmetic operations (operator precedence) is similar to other languages:

    1. Brackets (parenthesis), inner to outermost
    2. Exponentiation
    3. Multiplication and division (equal importance)
    4. Addition and subtraction (equal importance)

    The use of brackets helps user readability and reduces the likelihood of errors.

    • Since brackets take precedence over all operators, they effectively give control to you.
    • It is often helpful to use brackets even when not strictly necessary, so that the intended ordering is clearer.