Documentation

Simulink.SimulationInput class

Package: Simulink
Superclasses:

Creates SimulationInput objects to make changes to a model for multiple or individual simulations

Description

The Simulink.SimulationInput object allows you to make changes to a model and run simulations with those changes. These changes are temporarily applied to the model. Through Simulink.SimulationInput object, you can change:

  • Initial state

  • Model parameters

  • Block parameters

  • External inputs

  • Variables

Through the Simulink.SimulationInput object, you can also specify MATLAB® functions to run at the start and the end of each simulation by using in.PreSimFcn and in.PostSimFcn, respectively.Simulink.SimulationInput does not support the ability to allow model references to have their own data dictionary.

Construction

in = Simulink.SimulationInput('modelName') creates a SimulationInput object for a model.

Input Arguments

expand all

Create a Simulink.SimulationInput object by passing the name of the model as an argument.

Example: in = Simulink.SimulationInput('cstr')

Properties

expand all

Name of the model for which the SimulationInput object is created.

Initial state of the model for a simulation specified as a Simulink.SimState.ModelSimState object

External inputs added to the model for a simulation.

Block parameters of the model that are modified.

Variables of the model that are modified.

Model parameters of the model that are modified .

MATLAB function to run before the start of the simulation.

MATLAB function to run after the simulations.

Brief description of the simulation specified as a character array.

Methods

Method

Purpose

setModelParameter

Set model parameters to be used for a specific simulation through SimulationInput object.

setBlockParameter

Set block parameters to be used for a specific simulation through SimulationInput object.

setInitialState

Set initial state to be used for a specific simulation through SimulationInput object.

ExternalInput

Set external inputs for a simulation through SimulationInput object.

setVariable

Set variables for a simulation through SimulationInput object.

PreSimFcn

Specify a MATLAB function to run before start of each simulation through SimulationInput object.

PostSimFcn

Specify a MATLAB function to run after each simulation is complete through SimulationInput object.

applyToModel

Apply changes to the model specified through a SimulationInput object.

validate

Validate the contents of the SimulationInput object.

Examples

expand all

This example shows you how to create a SimulationInput object.

Create a single SimulationInput object for a model.

model = 'sldemo_househeat';
in = Simulink.SimulationInput(model);

This example shows you how to create an array of SimulationInput objects.

Create an array of SimulationInput objects by using the for loop.

model = 'vdp';
for i = 10:-1:1
   in(i) = Simulink.SimulationInput(model);
end

This example modifies the block parameters of a model through the SimulationInput object.

Open the model

mdl = 'sldemo_househeat';
open_system(mdl);

Create a SimulationInput object for this model.

in = Simulink.SimulationInput(mdl);

Modify block parameter.

in = in.setBlockParameter('sldemo_househeat/Set Point','Value','300');

Simulate the model.

out = sim(in)

Introduced in R2017a

Was this topic helpful?