setExternalInput

Set external inputs for a simulation through SimulationInput object, in

Description

example

in = in.setExternalInput([t, u1,..uN]) allows you to directly specify numerical arrays as inputs to a model if a model has root inports.

in = in.setExternalInput(ds) allows you to directly specify dataset objects as external inputs to a model if a model has root inports.

in = in.setExternalInput(ts) allows you to directly specify timeseries object as external input if a model has a single root inport.

Examples

collapse all

This example shows how to set numerical arrays as external inputs.

Open the model

open_system('sldemo_mdlref_counter');

Create a SimulationInput object for this model.

in = Simulink.SimulationInput('sldemo_mdlref_counter');

Prepare external inputs.

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

Set external inputs to the model.

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

Simulate the model.

out = sim(in);

Input Arguments

collapse all

Numerical array to be used as an external input.

Dataset object to be used as an external input

Time series to be used as an external input

Introduced in R2017a