bypassing 'keyboard' command with wrapper or something like using dbclear
    조회 수: 3 (최근 30일)
  
       이전 댓글 표시
    
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
댓글 수: 0
답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!