I have a habit of beginning all my MATLAB scripts with clear all; close all; clc
. While it has been a very useful line, as soon as it executes, it wipes out all my breakpoints. Is there a simple way to avoid that?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
I have solved this issue by creating a script that saves and reloads breakpoints. For convenience, you can even put it into a shortcut.
%# store breakpoints
tmp = dbstatus;
save('tmp.mat','tmp')
%# clear all
close all
clear classes %# clears even more than clear all
clc
%# reload breakpoints
load('tmp.mat')
dbstop(tmp)
%# clean up
clear tmp
delete('tmp.mat')
回答2:
clear all
is a heavy hammer. For example, it also dumps all the parsed MATLAB code already in memory. A simple clear
or one of the other options is usually a better choice and will not wipe your breakpoints.
回答3:
I had the same issue : after running my code, all breakpoints were deleted. I finally found that you could restore your last breakpoints by clicking on "Set / clear breakpoints" (F12 keypad).