To examine or specify the size of an argument, follow these steps:
From the MATLAB Function Block Editor, select Edit Data.
Enter the size of the argument in the Size field of the Data properties dialog, located in the General pane.
The default value is
Size defaults to
-1, which means that the
data argument inherits its size from Simulink® based on its scope:
|For Scope||Inherits Size|
|From the Simulink input signal connected to the argument.|
|From the Simulink output signal connected to the argument.|
|From the Simulink or MATLAB® parameter to which it is bound. See Add Parameter Arguments.|
After you compile the model, the Compiled Size column in the Contents pane displays the actual size used in the compiled simulation application.
The size of an output argument is the size of the value that is assigned to it. If the expected size in the Simulink model does not match, a mismatch error occurs during compilation of the model.
Note: No arguments with inherited sizes are allowed for MATLAB Function blocks in a library.
The size of a data argument can be a scalar value or a MATLAB vector of values.
To specify size as a scalar, set the Size field
to 1 or leave it blank. To specify Size as
a vector, enter an array of up to two dimensions in
column] format where
Number of dimensions equals the length of the vector.
Size of each dimension corresponds to the value of each element of the vector.
For example, a value of
[2 4] defines a
2-by-4 matrix. To define a row vector of size 5, set the Size field to
[1 5]. To
define a column vector of size 6, set the Size field
[6 1] or just
6. You can
enter a MATLAB expression for each
[row column] element
in the Size field. Each expression
can use one or more of the following elements:
Arithmetic operators, restricted to
The following examples are valid expressions for Size:
k+1 size(x) min(size(y),k)
In these examples,
y are variables of scope
Once you build the model, the Compiled Size column displays the actual size used in the compiled simulation application.