bypassing 'keyboard' command with wrapper or something like using dbclear

2 Ansichten (letzte 30 Tage)
aJackal
aJackal am 15 Jun. 2021
Bearbeitet: aJackal am 15 Jun. 2021
Hi Everybody,
I'm a scientist, and that means I'm often trying to cobble together something brand new using unfinished tools. We get it to work just long enough to learn if there's something interesting to write about, and then move on before the code is ever in a good state. Today's problem is that I want to test a large set of data using a tool that a colleague wrote. If their tool doesn't execute correctly for a given iteration, that's fine. I just want to continue onto the next loop.
So I wrapped the tool in a try-catch statement, but my colleague used the "keyboard" command as a debugging tool to pause execution and enter debug mode in the case of an unexpected event. That's fine. The tool is new, and it's useful for them to pause execution while they're still debugging the tool.
But for me, I just want to run the tool and take any output I can get across 10,000 test cases. Is there some kind of wrapper I can use to disable the keyboard command? I haven't had much luck searching for a solution since "keyboard" is such a common word unrelated to this function.
many thanks!
Example that replicates my problem:
function test_dbclear_keyboard
dbclear all %don't stop
for x=1:10000; %I don't want to restart
try
y=readonly_debugging(x);
catch
continue; %I don't care. Just keep going.
end
%do something with y
end
end
function y=readonly_debugging(x)
if x ~= 42
y=2*x;
else
keyboard; error(); %something's wrong. Stop and think about it
end
end

Antworten (0)

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Produkte


Version

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by