Suppose I put breakpoints in a script. I want to save these breakpoints so that I can reuuse them in a next session.
I have seen
https://stackoverflow.com/questions/12657219/how-to-restore-breakpoints-in-matlab-after-clear-all
Then what would be the specific steps to save breakpoints? Shall I just put
%# 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')
at the beginning of the script?

 채택된 답변

Jan
Jan 2018년 4월 30일

4 개 추천

No, do not insert this into the script. Keep the information about debugging and the actual code separated.
When you want to store the breakpoints, call:
status = dbstatus;
save('DBStatus.mat', 'status')
and to restore them, run:
Data = load('DBStatus.mat');
dbstatus(Data.status);
Maybe you want to store this in a function.

댓글 수: 5

alpedhuez
alpedhuez 2018년 4월 30일
It means I run this code on the command line? What will be the steps?
Jan
Jan 2018년 5월 1일
편집: Jan 2022년 8월 1일
It depends, on what you want to do exactly. Let me guess this important detail...
function dbstore(Command)
File = fullfile(prefdir, 'DBStatus.mat');
if narging == 0
status = dbstatus;
save(File, 'status');
else
Data = load(File);
dbstop(Data.status); % [EDITED], Typo fixed
end
end
Store this file as "dbstore.m" in one of your user-defined folders. Now call
dbstore
to store the breakpoints and
dbstore restore
(or any other argument) to restore the last saved breakpoints, either after a clear all, dbclear or restart of Matlab.
The loading routine should call
dbstop(Data.status)
to set breakpoints, not "dbstatus".
Omer Ben-Yshai
Omer Ben-Yshai 2019년 12월 31일
right.
Michael Needham
Michael Needham 2022년 8월 1일
This works, except for the last command I used dbstop(DataStat.status);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

제품

태그

질문:

2018년 4월 30일

편집:

Jan
2022년 8월 1일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by