How to restore breakpoints in MATLAB after “clear all”?

白昼怎懂夜的黑 提交于 2019-12-21 07:06:42

问题


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).



来源:https://stackoverflow.com/questions/12657219/how-to-restore-breakpoints-in-matlab-after-clear-all

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!