Once variables are created in MATLAB they can be used in a wide variety of mathematical operations. In Chapter 1 the variables that were used in mathematical operations were all defined as scalars. This means that they were all 1 × 1 arrays (arrays with one row and one column that have only one element) and the mathematical operations were done with single numbers. Arrays, however, can be one-dimensional (arrays with one row, or with one column), two-dimensional (arrays with multiple rows and columns), and even of higher dimensions. In these cases the mathematical operations are more complex. MATLAB, as its name indicates, is designed to carry out advanced array operations that have many applications in science and engineering. This chapter presents the basic, most common mathematical operations that MATLAB performs using arrays.

Addition and subtraction are relatively simple operations and are covered first, in Section 3.1. The other basic operations—multiplication, division, and exponentiation—can be done in MATLAB in two different ways. One way, which uses the standard symbols (*, /, and ^), follows the rules of linear algebra and is presented in Sections 3.2 and 3.3. The second way, which is called element-by-element operations, is covered in Section 3.4. These operations use the symbols .*, ./, and .^ (a period is typed in front of the standard operation symbol). In addition, in both types of calculations, MATLAB has left division ...

Start Free Trial

No credit card required