Compatible Array Sizes for Basic Operations
Most binary (two-input) operators and functions in MATLAB support numeric arrays that have
compatible sizes. Two inputs have compatible sizes if, for every dimension, the dimension sizes of the
inputs are either the same or one of them is 1. In the simplest cases, two array sizes are compatible if
they are exactly the same or if one is a scalar. MATLAB implicitly expands arrays with compatible
sizes to be the same size during the execution of the element-wise operation or function.
Inputs with Compatible Sizes
2-D Inputs
These are some combinations of scalars, vectors, and matrices that have compatible sizes:
• Two inputs which are exactly the same size.
• One input is a scalar.
• One input is a matrix, and the other is a column vector with the same number of rows.
• One input is a column vector, and the other is a row vector.
Compatible Array Sizes for Basic Operations
2-25
Most binary (two-input) operators and functions in MATLAB support numeric arrays that have
compatible sizes. Two inputs have compatible sizes if, for every dimension, the dimension sizes of the
inputs are either the same or one of them is 1. In the simplest cases, two array sizes are compatible if
they are exactly the same or if one is a scalar. MATLAB implicitly expands arrays with compatible
sizes to be the same size during the execution of the element-wise operation or function.
Inputs with Compatible Sizes
2-D Inputs
These are some combinations of scalars, vectors, and matrices that have compatible sizes:
• Two inputs which are exactly the same size.
• One input is a scalar.
• One input is a matrix, and the other is a column vector with the same number of rows.
• One input is a column vector, and the other is a row vector.
Compatible Array Sizes for Basic Operations
2-25
