MATLAB Answers

Resuming from "keyboard" command?

4 views (last 30 days)
Giuseppe Antonio
Giuseppe Antonio on 19 Nov 2019
Answered: Jan on 22 Nov 2019
I'm using the "keyboard" command to stop the execution in a nested (callback) function (which is triggered by a pushbutton) in order to make the user able to modify its workspace.
function myFunc()
function myNestedFunc(h,~)
openvar myGraph.Edges;
The problem is, that to exit from the debug mode, the user should run "dbcont" in the Command Window. But I want to resume as soon as he finished to edit the variable.
If I try to write another callback function like this:
function myFunc()
function resume(h,~)
I get the error "Debug commands only allowed when stopped in debug mode".
Is there a way to resume from "keyboard" without forcing the user to manually enter "dbcont" in the Command Window?
Giuseppe Antonio
Giuseppe Antonio on 22 Nov 2019
If I use the eval function, I get the error "Debug commands only allowed when stopped in debug mode". I don't know if this depends on the MATLAB versions, but I must use it.
Any suggestions on how to overcome this problem?

Sign in to comment.

Answers (1)

Jan on 22 Nov 2019
Using debug commands for an interaction with the user is a really bad design. A dynamic modification of the workspace is very fragile.
Resuming the debug mode througth another callback is strange also. Actually you should be able to check, if Matlab is in debug mode currently, but starting another callback while stopped in debug mode in another one, is at least confusing. Even including the dbcont in a try/catch block is not a smart solution - but worth to try for reasons of experiences.
Create a clean GUI for user interactions. Use the debugging methods only for debugging.

Community Treasure Hunt

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

Start Hunting!