Help CenterHelp Center
Clear variables from the model workspace of a model
clear(mdlWks)
clear(mdlWks, varName)
clear(mdlWks) removes all variables from the model workspace represented by the Simulink.ModelWorkspace object mdlWks.
mdlWks
Simulink.ModelWorkspace
example
clear(mdlWks, varName) removes the variable with the name varName from the model workspace mdlWks.
varName
collapse all
Open the example model vdp.
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 value 5.12 in the model workspace.
myVar
5.12
assignin(mdlWks,'myVar',5.12)
Clear all variables from the model workspace, including myVar.
Create a variable named var1 with value 5.12 in the model workspace.
var1
assignin(mdlWks,'var1',5.12)
Create another variable named var2 with value 7.5 in the model workspace.
var2
7.5
assignin(mdlWks,'var2',7.5)
Clear variable var1 from the model workspace.
clear(mdlWks, 'var1')
Target model workspace, specified as a Simulink.ModelWorkspace object.
Name of variable to remove, specified as a string or a character vector.
Introduced before R2006a
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office