MATLAB For Dummies, 2nd Edition
Book image
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 authors:

Jim Sizemore is professor of physics and engineering at Tyler Junior College. For over 25 years, Sizemore has worked in the semiconductor and software industries as a process engineer, device physicist, and software developer. John Paul Mueller has written more than 100 books and more than 600 articles on topics ranging from functional programming techniques to application development using C++.

This article can be found in the category: