you can do like this
set(0, 'DefaultFigureVisible', 'off');
set(0, 'DefaultAxesVisible', 'off'); % any image can not be visible in matlab
% do like plot and other operator
set(0, 'DefaultFigureVisible', 'on');
set(0, 'DefaultAxesVisible', 'on');