I found a solution, after you export your .mlapp file into .m file, add your flag to 'function createComponents(app,flag)' at the section:
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
use flag to create if condition for the related conponents would be ok.