Load Data to Test a Discrete Algorithm
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 that you want to import signal data for this 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
0. The 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 Loading Data Structures to Root-Level Inputs.
Select the Configuration Parameters > Data Import/Export > Input parameter and specify
import_varfor 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