Main Content

simulate

Class: sltest.TestCase
Namespace: sltest

Simulate model or Simulink.SimulationInput for MATLAB-based Simulink test

Since R2020b

Description

example

simout = simulate(testcase,model) simulates the specified model and returns a Simulink.SimulationOutput object.

example

simout = simulate(testcase,siminput) simulates using a Simulink.SimulationInput object as the siminput.

example

simout = simulate(testcase,Name,Value) simulates the model with additional options specified by one or more Name,Value pair arguments.

Input Arguments

expand all

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

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

Input object to simulate, specified as a sltest.harness.SimulationInput or Simulink.SimulationInput object.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'InFolder','C:\matlab\myTest'

Name of folder that contains the model to simulate, specified as the comma-separated pair consisting of 'InFolder' and the name of the folder, specified as a string or character vector.

Name of the harness to simulate, specified as the comma-separated pair of consisting of 'WithHarness', specified as a string or character vector.

Note

You can use the sim function name-value pairs with the simulate method.

Output Arguments

expand all

Simulation results, returned as a Simulink.SimulationOutput object.

Attributes

Accesspublic
Sealedtrue

To learn about attributes of methods, see Method Attributes.

Examples

expand all

classdef simTest < sltest.TestCase
    methods (Test)
        function testOne(testCase)
           simout = testCase.simulate('myModel');
        end
    end
end
classdef simTest < sltest.TestCase
    methods(Test)
        function testOne(testCase)
            simInput = Simulink.SimulationInput('myModel'); 
            simOut = testCase.simulate(simInput);
        end
    end
end
classdef simTest < sltest.TestCase
    methods(Test)
        function testOne(testCase)
           simout = testCase.simulate('myModel',...
             'InFolder','C:/matlab/newTestFolder');
        end
    end
end
classdef simTest < sltest.TestCase
    methods (Test)
        function testOne(testCase)
           simout = testCase.simulate('myModel',...
              'WithHarness','mymodel_Harness1');
        end
    end
end

Version History

Introduced in R2020b