Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Initialize a Matrix Using a Nontunable Structure Parameter

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:

Related Examples

More About

Was this topic helpful?