Main Content


Set external inputs for simulation on SimulationInput object



simIn = setExternalInput(simIn,inVals) sets external input data inVals on the Simulink.SimulationInput object simIn. The external input data defines the values loaded by root-level input ports in the model specified on the Simulink.SimulationInput object.


collapse all

Specify an array of external input data on a Simulink.SimulationInput object.

Open the model


Create a SimulationInput object for this model.

simIn = Simulink.SimulationInput('sldemo_mdlref_counter');

Create array of external input data.

t = (0:0.01:10)';
u1 = 5*ones(size(t));
u2 = 10*sin(t);
u3 = -5*ones(size(t));

Set external inputs on the Simulink.SimulationInput object.

simIn = setExternalInput(simIn,[t u1 u2 u3]);

Simulate the model.

out = sim(simIn);

Input Arguments

collapse all

Simulation inputs and configuration, specified as a Simulink.SimulationInput object.

External input data, specified as a Simulink.SimulationData.Dataset object, an array, or a timeseries object. The external input data specifies the values loaded by root-level input ports in the model. Use a timeseries object only when the model contains one input port.

Output Arguments

collapse all

Simulation configuration with external inputs added, returned as a Simulink.SimulationInput object.

Version History

Introduced in R2017a