removeVariable - Remove variable from SimulationInput or
Simulation object - MATLAB ([original](https://www.mathworks.com/help/simulink/slref/simulink.simulationinput.removevariable.html)) ([raw](?raw))
Remove variable from SimulationInput
orSimulation
object
Syntax
Description
[s](#mw%5Fbecfc0e0-516a-4573-b97a-95229d124d99) = removeVariable([s](#mw%5Fbecfc0e0-516a-4573-b97a-95229d124d99),[var](#mw%5F6d2a4d78-5ac4-4c35-90a0-aaffd43eae51))
removes the base workspace or data dictionary variable var
from theSimulink.SimulationInput or Simulation object s
.
[s](#mw%5Fbecfc0e0-516a-4573-b97a-95229d124d99) = removeVariable([s](#mw%5Fbecfc0e0-516a-4573-b97a-95229d124d99),[var](#mw%5F6d2a4d78-5ac4-4c35-90a0-aaffd43eae51),Workspace=[mdl](#mw%5Fc2ece433-7265-45f6-968f-550bc989bbc3))
removes the variable var
defined in the model workspace for the modelmdl
from the SimulationInput
orSimulation
object s
.
Examples
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
Simulation specification or simulation from which to remove variable, specified as aSimulink.SimulationInput object or aSimulation object.
Example: simin = removeVariable(simin,"k")
removes the base workspace or data dictionary variable k
from the simulation configuration stored in the SimulationInput
objectsimin
.
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
objectsimin
.
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 theSimulationInput
object simin
.
Example: sm = removeVariable(sm,"k",Workspace="MyModel")
removes the model workspace variable k
defined in the workspace for modelMyModel
from the Simulation
objectsm
.
Output Arguments
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 theSimulationInput
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
The Simulation
object represents a simulation and provides an interface to control simulation execution and tune model parameter, block parameter, and variable values during simulation. You can use the setVariable
, getVariable
, and removeVariable
functions to configure variable values for a single simulation and tune variable values during simulation.
See Also
Objects
Functions
- setVariable | loadVariablesFromMATFile | loadVariablesFromExternalSource | sim | parsim | batchsim | loadVariablesFromMATFile | validate