Main Content

removeVariable

Remove variable from SimulationInput or Simulation object

Description

example

s = removeVariable(s,var) removes the base workspace or data dictionary variable var from the Simulink.SimulationInput or Simulation object s.

s = removeVariable(s,var,Workspace=mdl) removes the variable var defined in the model workspace for the model mdl from the SimulationInput or Simulation object s.

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);

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

in = removeVariable(simIn,'cost');

Input Arguments

collapse all

Simulation specification or simulation from which to remove variable, specified as a Simulink.SimulationInput object or a Simulation object.

Example: simin = removeVariable(simin,"k") removes the base workspace or data dictionary variable k from the simulation configuration stored in the SimulationInput object simin.

Example: sm = removeVariable(sm,"k") removes the base workspace or data dictionary variable k from the Simulation object sm.

Variable to remove, specified as a string or a character vector.

Example: simin = removeVariable(simin,"k") removes the base workspace or data dictionary variable k from the simulation configuration stored in the SimulationInput object simin.

Example: sm = removeVariable(sm,"k") removes the base workspace or data dictionary variable k from the Simulation object sm.

Model workspace that contains variable to remove, specified as a string or a character vector.

Example: simin = removeVariable(simin,"k",Workspace="MyModel") removes the model workspace variable k defined in the workspace for model MyModel from the simulation configuration stored in the SimulationInput object simin.

Example: sm = removeVariable(sm,"k",Workspace="MyModel") removes the model workspace variable k defined in the workspace for model MyModel from the Simulation object sm.

Output Arguments

collapse all

Simulation specification or simulation with variable removed, returned as a Simulink.SimulationInput object or a Simulation object.

When you use the removeVariable function to remove a variable from a SimulationInput object, you must specify the SimulationInput object as the return argument.

When you use the removeVariable function to remove a variable from a Simulation object, assigning the return argument is optional.

Version History

Introduced in R2019a

expand all