Execute a command on exit from a workspace

조회 수: 7 (최근 30일)
Leo Simon
Leo Simon 2014년 4월 2일
답변: Leo Simon 2016년 2월 22일
Hi
I'd like to be able to execute a command immediately after I leave a function. In particular, I've written a function called myKeyboard, which does a few things (e.g., reports the results of dbstack), and then keyboards. But I'd like it to keyboard immediately after myKeyboard is completed, rather than within myKeyboard. From the documentation it looks as though the command
onCleanup
should do this, but it doesn't. It seems as though onCleanup only accepts functions as inputs, and executing a function on exit from myKeyboard would not accomplish what I want to accomplish
Thanks very much for any help...
Leo

채택된 답변

Leo Simon
Leo Simon 2016년 2월 22일
Here's an answer, obtained with the help of Matlab technical support
%Keyboards in the CALLER workspace not current workspace
tmpStack = dbstack;
eval(['dbstop in ' strtrim(strtok(tmpStack(end).name,'.')) ' at ' num2str(tmpStack(end).line + 1) ]);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Debugging and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by