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 Restrictions For Variable-Size Data.
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
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
its working dimension automatically, while
sum(X, dim) uses
the explicit working dimension.
For example, if
X is a variable-size matrix
sum(X,2) in generated code. In MATLAB®,
it behaves like
not 1. In MATLAB, when
size(X,2) is 1,
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 table list functions that have code generation restrictions for variable-size data. For additional restrictions for these functions, and restrictions for all functions and objects supported for code generation, see Functions and Objects Supported for C and C++ Code Generation — Alphabetical List.
|Function||Restrictions for Variable-Size Data|