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.

Create Data Arrays for Root-Level Inports

Data Array Format

This import format consists of a real (noncomplex) matrix of data type double. The first column of the matrix must be a vector of times in ascending order. The remaining columns specify input values.

  • Each column represents the input for a different Inport or Trigger block signal (in sequential order).

  • Each row is the input value for the corresponding time point.

For a Trigger block, the signal driving the trigger port must be the last data item.

The total number of columns of the input matrix must equal n + 1, where n is the total number of signals entering the model input ports.

Specify the Input Expression

The default input expression for a model is [t,u] and the default input format is Array. So if you define t and u in the MATLAB® workspace, simply select the Configuration Parameters > Data Import/Export > Input parameter to input data from the model workspace.

For example, suppose that you have a model with two Inport blocks:

  • The In1 block accepts two signals (the block has the Port dimensions parameter set to 2).

  • The In2 block accepts one signal (the block uses the default value for the Port dimensions parameter).

You define t and u in the MATLAB workspace:

numSteps = 9;
timeStep = 0.1;
t = (timeStep*(0:numSteps))';
u = [sin(t),cos(t),4*cos(t)];

When the simulation runs, the signal data sin(t) and cos(t) are assigned to In1 and the signal data 4*cos(t) is assigned to In2. Signal data is input for 100 time points.

    Note   The array input format allows you to load only real (noncomplex) scalar or vector data of type double. Use the structure format to input complex data, matrix (2-D) data, and data types other than double.

Arrays for Input Ports Driving Function-Call Subsystems

You can use an array to drive a Function-Call Subsystem through a root-level input port. You can use an array or an array that is an element of a Dataset object. The array must be an nx1 array. For the root-level Inport block, select the Output function call parameter.

For example, this Dataset object has an array element x:

ds = Simulink.SimulationData.Dataset;
x = [1 3 7 8]';
ds = ds.addElement(x,'theElementName');

This model uses the ds data set in the Configuration Parameters > Data Import/Export > Input parameter.

When you simulate the model, the time values of the logged signal data in the Function-Call Subsystem shows that the Function-Call Subsystem was triggered only for the times specified in array stored in ds.

>> logsout.get(1).Values.Time

ans =


See Also


Related Examples

More About

Was this topic helpful?