setExternalInput
Specify external input data for top-level input ports using
SimulationInput
or Simulation
object
Description
specifies the external input data s
= setExternalInput(s
,indata
)indata
on the Simulink.SimulationInput
or Simulation
object s
. Specifying external input
data on a SimulationInput
or Simulation
object is
equivalent to configuring the Input parameter in simulations
you run using the object. The model is modified during initialization to load the
external input data you specify, and the modifications revert when the simulation
completes.
In addition to specifying the data to for top-level input ports to load, the
setExternalInput
function:
Specifies the
LoadExternalInput
andExternalInput
parameters, as neededEnsures that the variables that contain the external input data are available for the simulation
You do not need to use the setModelParameter
or
setVariable
function to explicitly manage these aspects of
loading external input data for simulation.
Examples
Input Arguments
Output Arguments
Tips
To specify external input data for blocks that load data specified in a block parameter and not the Input parameter, specify the input data parameter for the block as a variable. Then, use the
setVariable
function to specify the value for the variable on aSimulationInput
orSimulation
object.For example, to specify the data to load for a From Workspace block, specify the Data parameter for the From Workspace block as a variable. Then, use the
setVariable
function to specify the value of the variable.To load input data from a file, ensure that the simulation can access the file that contains the input data. When you run simulations using the
parsim
andbatchsim
functions, you can send files to the workers using theAttachedFiles
name-value argument.
Version History
Introduced in R2017aSee Also
Objects
Simulink.SimulationInput
|Simulation
|Simulink.SimulationData.Dataset
|Simulink.SimulationData.DatasetRef
Functions
sim
|parsim
|batchsim
|setInitialState
|setVariable
|setBlockParameter
|validate