Main Content

simulate

Class: sltest.TestCase
Package: sltest

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

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.

Input object to simulate, specified as a Simulink.SimulationInput object.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

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.

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
Introduced in R2020b