主要内容

金宝appSimulink.SimulationInput类

Package:金宝app
Superclasses:

Creates模拟Input为了更改多个或单个模拟的模型的对象

Description

TheSimulink.SimulationInput对象允许您对模型进行更改,并通过这些更改运行模拟。这些更改暂时应用于模型。通过Simulink.SimulationInputobject, you can change:

  • 初始状态

  • Model parameters

  • Block parameters

  • External inputs

  • 变量

通过theSimulink.SimulationInput对象,您也可以指定MATLAB®functions to run at the start and the end of each simulation by usingin.setPreSimFcnIn.setPostSimfcn, respectively.

Construction

in= Simulink.SimulationInput('型号名称')creates a模拟Input模型的对象。

Input Arguments

expand all

Create aSimulink.SimulationInputobject by passing the name of the model as an argument.

Example:in = 金宝appsimulink.simulationInput('cstr')

Properties

expand all

Name of the model for which the模拟Inputobject is created.

初始状态of the model for a simulation specified as aSimulink.op.ModelOperatingPoint目的。

External inputs added to the model for a simulation.

修改模型的块参数。

变量的模式改变了d.

Model parameters of the model that are modified.

MATLAB函数在模拟开始之前运行。

MATLAB功能to run after each simulation.

Brief description of the simulation specified as a character array.

方法

Method

Purpose

setModelParameter

Set model parameters to be used for a specific simulation through模拟Input目的。

setBlockParameter

Set block parameters to be used for a specific simulation through模拟Input目的。

setInitialState

设置初始状态,用于通过模拟Input目的。

setExternalInput

设置外部输入以通过模拟Input目的。

setVariable

设置变量以通过模拟Input目的。

setPreSimFcn

Specify a MATLAB function to run before start of each simulation through模拟Input目的。

setPostsimfcn

Specify a MATLAB function to run after each simulation is complete through模拟Input目的。

applyToModel

Apply changes to the model specified through a模拟Input目的。

validate

Validate the contents of the模拟Input目的。

loadVariablesFromMATFile

Load variables from MAT-file into aSimulink.SimulationInput目的。

Examples

collapse all

此示例向您展示了如何创建一个模拟Input目的。

打开模型.

openexample(“金宝app simulink/openthemodelexample”);open_system('ex_sldemo_househeat');load_system('ex_sldemo_househeat')

Create a single模拟Input模型的对象。

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

此示例向您展示了如何创建一个n array of模拟Inputobjects.

Create an array of模拟Input对象通过使用forloop.

model ='vdp';fori = 10:-1:1 in(i)= s金宝appimulink.simulationInput(model);end

此示例通过模拟Input目的。

打开模型.

openexample(“金宝app simulink/openthemodelexample”);open_system('ex_sldemo_househeat');load_system('ex_sldemo_househeat')

Create a模拟Inputobject for this model.

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

Modify block parameter.

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

Simulate the model.

out = sim(in)

This example shows how useDatasetobjects to set external inputs withSimulink.SimulationInputobjects.

打开模型

mdl ='sldemo_mdlref_counter'; open_system(mdl);

Create aDatasetobject for this model.

t = (0:0.01:10)'; ds = Simulink.SimulationData.Dataset; ds = ds.setElement(1, timeseries(5*ones(size(t)),t)); % First element ds = ds.setElement(2, timeseries(10*sin(t),t)); % Second element ds = ds.setElement(3, timeseries(-5*ones(size(t)),t)); % Third element

Create aSimulink.SimulationInput对象并设置外部输入

in = Simulink.SimulationInput('sldemo_mdlref_counter');in = in.SetExternalInput('ds.getElement(1),ds.getElement(2),ds.getElement(3)');

在表达式中添加其他剩余变量。确保数据集也在模拟Input目的。

Simulate the model.

in = in.setVariable('ds',ds);

Simulate the model

out = parsim(in)

Version History

Introduced in R2017a