The publish
command calls a private function evalmxdom
to actually run the code in your file. You can find evalmxdom
at $matlabroot%\toolbox\matlab\codetools\private\evalmxdom.m
, where $matlabroot$
is your MATLAB installation directory.
If you read through it, you'll find a section at around line 60 where it stores the current breakpoints, turns them all off, and then sets things up so that the original breakpoints are restored when publishing is finished.
You'll notice that the code calls a subfunction safeDbclear
that clears the breakpoints. Try commenting out the contents of that subfunction, and publishing again.
NB:
- I'm on R2017a: if you're on a different version and this file has changed between versions, the line numbers may be different.
- Be careful: you will be modifying files that are part of your MATLAB installation here. Take a backup of the file before you make a change to it.
- This may well mess up some aspects of publishing - it's turning off breakpoints for a reason.