You can do it as follows:
% Get access to matlab desktop
desktop = com.mathworks.mde.desk.MLDesktop.getInstance();
% Close the variable editor
desktop.closeGroup('Variables');
Note. If you want, use desktop.getGroupTitles()to get a name for other windows ("Command History", "Workspace", etc.).
source
share