Section 8.8 MATLAB as a Glorified Calculator
Even though we spent the preceding section praising MATLAB for its powerful capabilities we are going to spend the rest of this chapter learning how to use it as a calculator. It is going to seem that this is boring and easy, however, there are key concepts that are easy to miss! To best learn, I recommend that you open MATLAB and practice these concepts in the MATLAB command window.
Arithmetic Operators (for Scalar)
To use MATLAB as a calculator, we first need to learn what symbols are reserved for use as arithmetic operators. Keep in mind this section only applies to arithmetic performed on scalars (A quantity (such as mass or time) that has a magnitude describable by a real number and no direction. In other words, it is NOT a vector!). Future chapters will cover mathematical operations with vectors. Most of the following operators should seem pretty obvious to you.

Now that we know the symbols, we can execute basic mathematical operations in MATLAB!
Here is an interactive code box for checkpoint 8.8.2
Important Symbols and Commands
As we continue throughout this book, we will be adding to the list of MATLAB commands and reserved symbols. For now, these symbols and commands are the ones that I think are the most important for you to learn.

Order of Precedence
Analogous to what you learned in previous mathematics courses about order of operations (A lot of you probably learned an acronym like PEMDAS: Parenthesis, Exponents, Multiplication/Division, Addition/Subtraction) MATLAB has a built-in order of precedence. The concept is the same, the order of precedence is built into MATLAB and specifies the order in which mathematical operations will be performed.
As we learn new operators (specifically logical and relational) we will be updating this list. For now, the MATLAB Order of Precedence is as follows.
-
Parentheses
-
Exponentiation
-
Multiplication / Division
-
Addition / Subtraction
Try It!
For example, consider if MATLAB were to execute the following two mathematical operations:
>> 4 + 6 * 2
and
>> (4 + 6) * 2
In the first instance, based on the order of precedence, the result would be
16. Why? MATLAB will evaluate the 6 * 2 portion of the operation first, as it is higher in order of precedence than addition.
In the second instance, the result would be
20. In this case, the operations in the parentheses will be evaluated first (4 + 6) and then the result of that will be multiplied by 2.
Checkpoint 8.8.4. Order of Precedence with Arithmetic.
You have attempted of activities on this page.
