Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Execute a keyboard *after* exiting from a function

Subject: Execute a keyboard *after* exiting from a function

From: Leo Simon

Date: 21 Jul, 2012 04:34:07

Message: 1 of 4

I'd like to be able to do the following, from within a function: exit the function and *after exiting* go into keyboard mode. For example, if an error occurs within a function call, I'd like to be able to get back to the caller workspace *before* keyboarding. This seems to me to be impossible in matlab, but maybe somebody else knows how to do this...

Subject: Execute a keyboard *after* exiting from a function

From: Bruno Luong

Date: 21 Jul, 2012 06:46:07

Message: 2 of 4

"Leo Simon" <leosimon@berkeley.edu> wrote in message <judbfv$ksu$1@newscl01ah.mathworks.com>...
> I'd like to be able to do the following, from within a function: exit the function and *after exiting* go into keyboard mode. For example, if an error occurs within a function call, I'd like to be able to get back to the caller workspace *before* keyboarding. This seems to me to be impossible in matlab, but maybe somebody else knows how to do this...

dbstep out

Bruno

Subject: Execute a keyboard *after* exiting from a function

From: Kristin

Date: 21 Jul, 2012 06:52:07

Message: 3 of 4

"Leo Simon" <leosimon@berkeley.edu> wrote in message <judbfv$ksu$1@newscl01ah.mathworks.com>...
> I'd like to be able to do the following, from within a function: exit the function and *after exiting* go into keyboard mode. For example, if an error occurs within a function call, I'd like to be able to get back to the caller workspace *before* keyboarding. This seems to me to be impossible in matlab, but maybe somebody else knows how to do this...

From what I understand, you would like to catch the error that occurs in your function and handle said error in the caller workspace. Wrap it around a TRY-CATCH statement:

try
   myfunc(a,b,c,d); % call the function
catch ME
   disp(ME); % display the error
   % do what you like here.
end

If you're just trying to debug, you can always keyboard from wherever and use DBUP, which will place the keyboard in the caller function....
Hope this helps!

Subject: Execute a keyboard *after* exiting from a function

From: Steven_Lord

Date: 23 Jul, 2012 14:03:27

Message: 4 of 4



"Leo Simon" <leosimon@berkeley.edu> wrote in message
news:judbfv$ksu$1@newscl01ah.mathworks.com...
> I'd like to be able to do the following, from within a function: exit
> the function and *after exiting* go into keyboard mode. For example,
> if an error occurs within a function call, I'd like to be able to get back
> to the caller workspace *before* keyboarding. This seems to me to be
> impossible in matlab, but maybe somebody else knows how to do this...

You could DBSTOP IF ERROR and then use DBUP, or use the graphical
equivalents of those commands.

http://www.mathworks.com/help/techdoc/ref/dbup.html

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us