Programming and Data Types | ![]() ![]() |
Operating Element-by-Element
MATLAB functions that operate element-by-element on two-dimensional arrays, like the trigonometric and exponential functions in the elfun
directory, work in exactly the same way for multidimensional cases. For example, the sin
function returns an array the same size as the function's input argument. Each element of the output array is the sine of the corresponding element of the input array.
Similarly, the arithmetic, logical, and relational operators all work with corresponding elements of multidimensional arrays that are the same size in every dimension. If one operand is a scalar and one an array, the operator applies the scalar to each element of the array.
![]() | Computing with Multidimensional Arrays | Operating on Planes and Matrices | ![]() |