clear - Clear variables from the model workspace of a model - MATLAB (original) (raw)
Main Content
Clear variables from the model workspace of a model
Syntax
Description
clear([mdlWks](#d126e740382))
removes all variables from the model workspace represented by the Simulink.ModelWorkspace
object mdlWks
.
clear([mdlWks](#d126e740382), [varName](#mw%5F608a4a0d-2dfb-4fdc-9a92-fad5f6cf8e37))
removes the variable with the name varName
from the model workspace mdlWks
.
Examples
Open the example model vdp
.
openExample('simulink_general/VanDerPolOscillatorExample')
Create a Simulink.ModelWorkspace
object that represents the model workspace of vdp
.
mdlWks = get_param('vdp','ModelWorkspace');
Create a variable named myVar
with value5.12
in the model workspace.
assignin(mdlWks,'myVar',5.12)
Clear all variables from the model workspace, includingmyVar
.
Open the example model vdp
.
openExample('simulink_general/VanDerPolOscillatorExample')
Create a Simulink.ModelWorkspace
object that represents the model workspace of vdp
.
mdlWks = get_param('vdp','ModelWorkspace');
Create a variable named var1
with value5.12
in the model workspace.
assignin(mdlWks,'var1',5.12)
Create another variable named var2
with value7.5
in the model workspace.
assignin(mdlWks,'var2',7.5)
Clear variable var1
from the model workspace.
Input Arguments
Target model workspace, specified as aSimulink.ModelWorkspace
object.
Name of variable to remove, specified as a string or a character vector.
Version History
Introduced before R2006a