The following simple example uses a nontunable structure parameter input to initialize a matrix output. The model looks like this:
This
model defines a structure variable p
in its pre-load
callback function, as follows:
The structure p
has two fields, rows
and cols
,
which specify the dimensions of a matrix. The MATLAB Function block
uses a constant input u
to initialize the matrix
output y
. Here is the code:
function y = fcn(u, p) y = zeros(p.rows,p.cols) + u;
Running
the model initializes each element of the 2-by-3 matrix y
to
99, the value of u
: