Discrete signals are signals that you define using evenly-spaced time values. One signal value is read at each time step, using the sample time of the source block.
Use a structure that has an empty time vector, which results in the model using the sample time of the source block. Using this approach avoids possible mismatches between the vector and the Simulink® time steps. The double-precision rounding used by computers and the values expected by Simulink can differ.
Suppose you want to import signal data for this very simple model.
In the Block Parameters dialog box for the Inport block:
Set the sample time.
Clear the Interpolate data parameter.
For the data that you want to import, specify a structure
variable that does not include a time vector.
For example, for the variable called
import_var.time = ; import_var.signals.values = [0; 1; 5; 8; 10]; import_var.signals.dimension = 1;
The input for the first time step is read from the first element
of an input port value array. The value is
value for the second time step is read from the second element of
the value array (
1), and so on.
For details about how to specify the signal value and dimension data, see Specify Signal Data.
Select the Configuration
Parameters > Data Import/Export > Input parameter and specify
the data to import.
If you are using a From Workspace block to import data, use
a similar approach. In addition, set the Form output after
final data value by parameter to a value other than