Sounds like you want to toggle output on and off probably for debugging purpose. In that case, you should be using the debugging tools instead.
Otherwise, a well written program should be explicit about wanting to display something to the command window, not leave it to the absence of a semi-colon, which most people (and matlab code analyser) would consider a coding error. So:
something = someexpression; %always terminate with semicolon
if dooutput
disp(something); %Now it's clear that you want to display it and that it's not a mistake
Best Answer