Main Content

createSimulationInput

Create simulation input object

Syntax

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

Description

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

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

Input Arguments

expand all

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.

Attributes

Accesspublic
Sealedtrue

To learn about attributes of methods, see Method Attributes.

Examples

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',...
               'WithHarness','myExample_Harness1');
            simOut = testCase.simulate(in);
            testCase.verifySignalsMatch(simOut,'myExampleBaseline.mat');
        end
    end 
end

Introduced in R2021a