how to remove all variables in the workspace

39 visualizaciones (últimos 30 días)
tevzia
tevzia el 3 de Sept. de 2013
Respondida: Hans Scharler el 22 de Sept. de 2022
Hi, I try to remove/clear all the variables in the work space. But not typing clear on the command window. I try to add clear at the beginning of the my code. but it doesnt work. is there any way to add clear or any other way to clear workspace when i run mycode

Respuestas (2)

Hans Scharler
Hans Scharler el 22 de Sept. de 2022
You can use clear command and specifiy the variable name right in your code.
newVar = 42
newVar = 42
newVar = newVar + 3
newVar = 45
clear newVar
newVar
Unrecognized function or variable 'newVar'.

Image Analyst
Image Analyst el 3 de Sept. de 2013
Editada: Image Analyst el 3 de Sept. de 2013
Try "clearvars" or "clear all" as a line in your script. Do not do this in a function that takes input arguments or else you will blow them away!!!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by