| SystemTest™ | ![]() |
| On this page… |
|---|
Overriding Inport Block Signals in a Simulink Element Example: Overriding Simulink Inport Blocks Using a Spreadsheet Data Test Vector |
The examples in Mapping Test Vectors and Test Variables to a Simulink Model described how to override block parameters and workspace variables. Similarly, you can override signals to root-level Inport blocks in Simulink with SystemTest data.
Because the Simulink element uses the Inport block names, not the port numbers, your test works even if you reorder the Inport blocks in the model.
Some users store signal values in a Microsoft Excel spreadsheet or .csv file. You can create a test vector that reads values from a spreadsheet and use that as your Inport block signal mapping. The Example: Overriding Simulink Inport Blocks Using a Spreadsheet Data Test Vector section shows such a scenario.
To override Inport block signals:
If you have a model that contains Inport blocks and you have created a Simulink element that uses that model, click the Mappings tab inside the Simulink element.
Expand the Override Inport Block Signals with SystemTest Data section by clicking the expander arrow on the right side of the section title.
Designate your mappings.
The user interface indicates how many Inport blocks your model contains. For example, the model used in the Simulink Input demo contains three Inport blocks, as shown here. You can open this demo by typing the following in the MATLAB command line:
systemtest SimulinkInputDemo1

The first option, Do not override Inport block signals, is selected by default. That means the test will run the model without modifying any Inport block settings. Any data the Inport blocks are configured to use will be used during execution. If you want to override the model, use one of the other two options.
The All Inport blocks are mapped using option allows you to map data to all Inport blocks at once. Use the drop-down list to choose an existing test vector or test variable, or to create a new one. This supports any data format the Simulink model supports. For example, it could be a test vector that is an array of time and three signal values, such as [time, U1, U2, U3].
If you want to map individual Inport blocks, select the Individual Inport blocks are mapped using option.

When you select this option, the mapping table becomes editable. In the case shown here, In1 and In2 are being overridden with SystemTest data, and In3 is using the value in the model.
The table displays all Inport blocks contained in the model. By default, the SystemTest Data column is assigned as Inherit from model. This is especially convenient if you have a large number of Inport block signals and only want to override a small number of them in your test. You would just change the SystemTest Data column value for the ones you want to override.
You can update the list of Inport blocks that are displayed in the table by clicking the Open and update model state button in the Simulink element. The Inports listed in the table are sortable.
If you are using individual mappings, you need to define the test signal time and the end time. If you are using either of the other mapping options (inherit from model or map all), skip this step since the time options only apply to individual mappings.
In the Define test signal time option, you can specify the simulation time signal to provide to the model. To specify the time signal using a test vector or test variable, select Map test signal time to. To specify a time signal based on a desired simulation time step, select Manually specify a time step and then enter a valid time step, which must be a positive number.
In the To calculate end time of simulation option, either use the model's stop time, or use the signal's end time based on the time step you specified. The Use model stop time option stops the simulation of the model at the end time configured in the model. The Use signal's end time option stops the simulation of the model at the end of the test signal, temporarily overriding the end time of the model with the test signal end time.
In this example, a Simulink element is being used to test a model of a fuel rate controller. To see the test and the model, open the demo by typing the following at the MATLAB command line:
systemtest('demosystest_fuelctrlsldv.test');The model has four Inport blocks that represent throttle angle, engine speed, exhaust gas, and manifold pressure.

The tester has values for these four blocks in a Microsoft Excel spreadsheet. It contains 37 sets of generated values for the blocks. Each set of values is on a different sheet within the spreadsheet, representing a testing scenario for the model. One of the sheets is shown here.

Column A represents the simulation time signal. Columns B through E represent test data for the four Inports in the model. Each of the 37 sheets is set up the same way but contains different values.
To set up the test vector that reads the data from the spreadsheet:
Create the test vector by clicking the New button in the Test Vectors pane.
In the Insert Test Vector dialog box, select Spreadsheet Data as the vector type.
On the General tab, name the test vector InputSignal.
Click the Add File button and browse to the Microsoft Excel spreadsheet.

Click the Select All button to select all sheets in the spreadsheet file.
On the Data Selection tab, keep the default of column in the Data is arranged by option.
In the Read data from column option, enter A to E, starting at row 1.
Select the First row is a header option, since you can see in the above figure of the spreadsheet that row 1 of the file contains text labels.
Select the Treat each selected sheet as a test vector value option.
The configured test vector appears as follows.

Click OK in the Insert Test Vector dialog box.
The new vector appears in the table in the Test Vectors pane. You can see that the length is 37 because there are 37 sheets in the spreadsheet file and each sheet is being treated as one value in the vector.

Now that the test vector is set up, you can set up the Simulink element to override the Inport blocks using the test vector values from the underlying spreadsheet file.
Create a Simulink element by clicking New > Test Element > Simulink button in the Test Browser.
Click the browse button to locate the Fuel Rate Controller model.
On the Mappings tab, expand the Override Inport Block Signals with SystemTest Data section if it is not open.
Select the Individual Inport blocks are mapped using option. The four Inport blocks appear in the table.
For each Inport block, use the drop-down list in the SystemTest Data column to override the Inport block with the appropriate data in the test vector that was created earlier.
For example, for throttle, click the drop-down list, expand the InputSignal test vector entry, and select throttle. Do the same for the other three signals.
The entries under the InputSignal test vector represent the underlying columns in the spreadsheet. Since the Spreadsheet Data test vector called InputSignal was created using the columns and the headers, the columns appear named with their headers in the list for easy identification, for example, InputSignal(throttle).
In the Define test signal time option, select Map test signal time to and choose InputSignal(Time).
Time is the first column in the spreadsheet and contains the simulation time signal for the model. The test will use these time step values when the Simulink element is executed.
Select the Use signal's end time option, so that the end times provided in the spreadsheet are used.
The configured Simulink element appears as follows.

When the test is executed, the Simulink element will test the model using the Inport block signals mapped from the spreadsheet.
![]() | Mapping Test Vectors and Test Variables to a Simulink Model | Using Simulink Model Coverage | ![]() |
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |