주요 콘텐츠

simulate

R2026b

Class: sltest.TestCase
Namespace: sltest

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

Description

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 arguments.

example

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

expand all

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.

Example: InFolder="C:\matlab\myTest"

Name of folder that contains the model to simulate, specified as a string or character vector.

Name of the harness to simulate, specified as a string or character vector.

Note

You can use the sim function name-value arguments 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