|On this page…|
The following common restrictions apply to multiple toolbox functions, but only for code generation. To determine which of these restrictions apply to specific library functions, see the table in Toolbox Functions with Variable Sizing Restrictions.
Inputs to the library function must be variable-length vectors or fixed-size vectors. A variable-length vector is a variable-size array that has the shape 1x:n or :nx1 (one dimension is variable sized and the other is fixed at size 1). Other shapes are not permitted, even if they are vectors at run time.
When the function selects the working dimension automatically, it bases the selection on the upper bounds for the dimension sizes. In the case of the sum function, sum(X) selects its working dimension automatically, while sum(X, dim) uses dim as the explicit working dimension.
For example, if X is a variable-size matrix with dimensions 1x:3x:5, sum(x) behaves like sum(X,2) in generated code. In MATLAB®, it behaves like sum(X,2) provided size(X,2) is not 1. In MATLAB, when size(X,2) is 1, sum(X) behaves like sum(X,3). Consequently, you get a run-time error if an automatically selected working dimension assumes a length of 1 at run time.
To avoid the issue, specify the intended working dimension explicitly as a constant value.
The function issues an error when a variable-size array that is not a variable-length vector assumes the shape of a vector at run time. To avoid the issue, specify the input explicitly as a variable-length vector instead of a variable-size array.
The function issues an error if a variable-size array assumes a scalar value at run time. To avoid this issue, specify scalars as fixed size.
The following restrictions apply to specific toolbox functions, but only for code generation.
|Function||Restrictions with Variable-Size Data|