Main Content


Create simulation input object


inputObj = createSimulationInput(testCasemodel)
inputObj = createSimulationInput(testcase,model,'WithHarness',harness)


inputObj = createSimulationInput(testCasemodel) creates a Simulink.SimulationInput or sltest.harness.SimulationInput object for the specified testCase and model. If the model is not loaded, createSimulationInput uses testCase.loadSystem to loads the model when you simulate it.

inputObj = createSimulationInput(testcase,model,'WithHarness',harness) creates an sltest.harness.SimulationInput object for the specified test harness.

Input Arguments

expand all

Instance of the test case, specified as an sltest.TestCase object.

Name of the model, specified as a string or character vector, without the model extension. For example, for the myModel.slx model, enter only myModel.

Example: 'RollAutopilotModelRef'

Name of the harness, specified as a comma-separated pair of consisting of 'WithHarness' and the name of the test harness for which to create input, specified as a string or character vector.

Example: 'WithHarness','RollAutopilotModelRef_harness1'

Output Arguments

expand all

Simulation input object, returned as a Simulink.SimulationInput or sltest.harness.SimulationInput object. To use the simulation input with a test harness, use the WithHarness syntax to return an sltest.harness.SimulationInput object. If you do not use the WithHarness option, this function returns a Simulink.SimulationInput. You use these objects to pass inputs to a harness or model, respectively.



To learn about attributes of methods, see Method Attributes.


expand all

Create a MATLAB®-based Simulink® test file named testSim.m.

In the file, define the test case in the testOne function. The function creates the simulation input for a harness called myExample_harness1, simulates using that input, and compares the simulation output to a baseline file.

classdef testSim < sltest.TestCase
    methods (Test)
        function testOne(testCase)
            in = testCase.createSimulationInput('myExample',...
            simOut = testCase.simulate(in);

Version History

Introduced in R2021a