Introduction
During data processing, sometimes some variables occupy a large amount of memory space. After using them, you need to consider releasing the memory. Here are several ways to release variable memory.
clearvars syntax
clearvars
clearvars variables
clearvars -except keepVariables
clearvars variables -except keepVariables
clearvars -global ___
Here you can delete multiple variables at once, except for a certain variable, and use regular expressions to delete variables.
Specific usage: https://ww2.mathworks.cn/help/matlab/ref/clearvars.html
clear syntax
clear
clear name1 ... nameN
clear -regexp expr1 ... exprN
clear ItemType
Specific usage: https://ww2.mathworks.cn/help/matlab/ref/clear.html