Scalar expansion is a method of converting scalar data to match the dimensions of vector or matrix data. For example, in this assignment, scalar expansion converts a value of 1 to a vector or matrix where all the elements are 1:
A = 1;
Scalar expansion is supported only in Stateflow® charts that use C as the action language.
Suppose that you have a function signature
yy = f(uu), where
the formal arguments
uu are scalars.
Assume that you have a function call
y = f(u). The rules of
scalar expansion for function calls with a single output follow.
|Output ||Input ||Result|
|Scalar||Scalar||No scalar expansion occurs.|
|Vector or matrix||Scalar||Scalar expansion occurs for |
|Vector or matrix||Vector or matrix||Scalar expansion occurs so that |
|Scalar||Vector or matrix||An error message alerts you to a size mismatch.|
For functions with multiple outputs, the same rules apply except for the case where the outputs and inputs of the function call are all vectors or matrices. In this case, scalar expansion does not occur, and an error message alerts you to a size mismatch.
The rules of scalar expansion apply to all functions that you use in Stateflow charts:
Truth table functions