Typically when importing a test case in Simulink®, you want to:
Create a signal that has ramps and steps. In other words, the signal has one or more discontinuities.
Create the signal using the fewest points possible.
Have the Simulink solver execute at the specified discontinuities.
To import this signal in Simulink, use a From Workspace, From File, or Signal Builder block, all of which support zero-crossing detection.
The following is an example of test case data:
The following two examples use this test case data.
Enable zero-crossing detection. In the From Workspace block dialog, select Enable zero-crossing detection.
Create a signal structure for the test case. At each discontinuity, enter a duplicate entry in the time vector. As described in the From Workspace block documentation, this generates a zero-crossing and forces the variable-step solver to take a time step at this exact time.
var structure representing the
var.time = [0 1 1 5 5 8 8 10]; var.signals.values = [0 0 2 2 2 3 3 3]'; var.signals.dimensions = 1;
To import the test case structure, in the From Workspace
block dialog, in the Data parameter, specify
Simulate the model. The Scope block reflects the test case data.
As an alternative to using a From Workspace block, you can use a Signal Builder block to either create a signal interactively or to import a signal from a MAT-file.
Create a structure and save it in a MAT-file:
var.time = [0 1 1 5 5 8 8 10]; var.signals.values = [0 0 2 2 2 3 3 3]'; var.signals.dimensions = 1; var.signals.label = 'var'; save var.mat var
Double-click the Signal Builder block to open its dialog box.
Select File > Import From File menu item,
and select the
In the Select parameter, select
existing dataset. In the Data to Import section,
select the Select All check box. Confirm the
selection and click OK.
The Signal Builder block display reflects the test case data.
For a detailed example that shows how to use a Signal Builder block as the input source for your model and to import your own signal data to the model, see Prepare Simulation.