Home

MATLAB Operator Precedence

|
|  Updated:  
2016-03-26 08:32:29
|   From The Book:  
MATLAB For Dummies
Explore Book
Buy On Amazon

Knowing the order in which tasks are performed is essential. Otherwise, the formulas you type won't work as expected and you'll obtain errant results. The following table shows the order in which MATLAB evaluates various operators.

You can also remember operator precedence using the PEMDAS acronym, which stands for Parentheses, Exponent, Multiply And Divide, Add and Subtract.

Operator Description
() Parentheses are used to group expressions and to override the default precedence so that you can force an operation of lower precedence (such as addition) to take precedence over an operation of higher precedence (such as multiplication).
.' .^ ' ^ Transpose, power, complex conjugate transpose, matrix power.
+ - ~ Unary operators interact with a single variable or expression.
.* ./ . * / Multiplication and division(both right and left).
+ - Addition and subtraction.
: Colon operator (used for ranges).
>= Comparison operators.
== ~= Equality operators.
& | Logical operators (element-wise).
&& || Logical operators (short-circuit).

About This Article

This article is from the book: 

About the book author:

Jim Sizemore is Professor of Physics and Engineering at Tyler Junior College. For over 25 years he s worked in the semiconductor and software industries as a process engineer, device physicist, and software developer and has been teaching college physics, engineering, and math for the last 13 years.

John Paul Mueller is a freelance author and technical editor. He has writing in his blood, having produced 100 books and more than 600 articles to date. The topics range from networking to home security and from database management to heads-down programming. John has provided technical services to both Data Based Advisor and Coast Compute magazines.