Financial Toolbox | ![]() ![]() |
Operating Element-by-Element
Finally, element-by-element arithmetic operations are called array operations. To indicate an array operation in MATLAB, precede the operator with a period (.
). Addition and subtraction, and matrix multiplication and division by a scalar, are already array operations so no period is necessary. When using array operations on two matrices, the dimensions of the matrices must be the same. For example, given vectors of stock dividends and closing prices
Dividends = [1.90 0.40 1.56 4.50]; Prices = [25.625 17.75 26.125 60.50]; Yields = Dividends ./ Prices Yields = 0.0741 0.0225 0.0597 0.0744
![]() | Solving Simultaneous Linear Equations | Function Input/Output Arguments | ![]() |