MATLAB For Dummies
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:

John Paul Mueller is an author and technical editor with experience in application development, database management, machine learning, and deep learning. He has written hundreds of books and articles helping everyday people learn everything from networking to database management.

John Mueller has produced 114 books and more than 600 articles on topics ranging from functional programming techniques to working with Amazon Web Services (AWS). Luca Massaron, a Google Developer Expert (GDE),??interprets big data and transforms it into smart data through simple and effective data mining and machine learning techniques.

This article can be found in the category: