Remove progress bar from published document in MATLAB

I am using the publishing functionality of MATLAB to generate a quick report of some analysis I'm running. Since the analysis is quite time-consuming, I've added a progress bar to keep track of how long is remaining. The problem is that I'd prefer this progress bar not to appear in my report.

Is there a way to keep MATLAB from introducing some content in a published document. Or, alternatively, is there a way I can know I'm currently in publish mode, so I can skip the progress bar in those cases?

Edit: There's a couple of solutions already, but I'd prefer something automatic that doesn't require an extra step in the workspace before publication. Any other tricks?


ANSWERS:


AFAIK there is no way of excluding parts from published document.

Perhaps what you can do is to output a unique pattern (BEGIN/END) around the progress bar code, which you will then parse the html file and remove those sections using some script.


I'm assuming you're using the WAITBAR function to generate a progress bar, and you have only one of these waitbars in your function.

Before you publish the file pre-create the waitbar:

h = waitbar(0);

Then make the waitbar invisible to the PUBLISH function:

set(h,'HandleVisibility','off')

Where you use the waitbar in your code, you have to specify that you want to reuse the hidden waitbar by referring to it again, with the handle, h:

waitbar(newPercentage,h);

see the function reference page for waitbar for more help.


Another slightly more generic option (inspired by Mike Katz' response), which works for any kind of content you don't want (or explicitly want) to include in your report.

in your module/function

try
   inPublishMode = evalin('base', 'inPublish');
catch
   inPublishMode = false;
end

You can now set the inPublish variable from the workspace before running your test, and wrap your optional code in conditional statements.

if inPublishMode
    % do something
end

Still not perfectly satisfactory, but it's another tool in the bag.



 MORE:


 ? What is the basic idea behind programming a progress/status bar in MATLAB?
 ? Text progress bar in Matlab
 ? MATLAB update waitbar
 ? xlsread and waitbar MATLAB
 ? How to modify xlsread to get a step-by-step updated flag from loading process
 ? How can I make waitbar in MATLAB modal
 ? Get waitbar value in Matlab
 ? waitbar matlab before start a standalone script
 ? matlab progress bar not depanding on time
 ? JavaFX ProgressBar/ProgressIndicator: listen for change from multiple Sliders