Import Data Arrays

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. In particular, each column represents the input for a different Inport or Trigger block signal (in sequential order) and 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's 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, you need only select the Input option to input data from the model workspace. For example, suppose that a model has two input ports, In1 that accepts two signals, and In2 that accepts one signal. Also, suppose that the MATLAB workspace defines t and u as follows:

N = 10;
Ts = 0.1
t = ((0:N)* Ts)';
u = [sin(t), cos(t), 4*cos(t)];

When the simulation runs, the signals sin(t) and cos(t) will be assigned to In1 and the signal 4*cos(t) will be assigned to In2.

    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/or 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 a Dataset element. The array must be an nx1 array. For the root-level Inport block, you select Output function call.

For example, if you have a Dataset object with an array element:

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, you see that the Function-Call Subsystem was triggered only for the times specified in array stored in ds.

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

ans =

Was this topic helpful?