Main Content

removeVariable

Remove variable from Simulink.SimulationInput object

Since R2019a

Description

example

simIn = removeVariable(simIn,varName) removes the variable with the name varName from the Simulink.SimulationInput object simIn.

simIn = removeVariable(simIn,varName,'Workspace',wkspace) removes the variable with the name varName specified in the workspace wkspace from the Simulink.SimulationInput object simIn.

Examples

collapse all

Open the model.

openExample('simulink/OpenTheModelExample');
open_system('ex_sldemo_househeat');

Create a SimulationInput object for this model.

in = Simulink.SimulationInput(mdl);

Set the cost variable value to 50.

in = setVariable(simIn,'cost',50);

By default, this variable is placed in the global workspace scope.

Suppose you want to simulate using the variable value saved in the model. Remove the variable from the Simulink.SimulationInput object.

in = removeVariable(simIn,'cost');

Input Arguments

collapse all

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

Name of variable to remove, specified as a string or a character vector.

Example: 'Gain'

Workspace from which to remove variable, specified as a string or a character vector.

Example: 'Workspace', 'sldemo_househeat'

Output Arguments

collapse all

Simulation configuration with variable removed, returned as a Simulink.SimulationInput object.

Version History

Introduced in R2019a