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

dbstop if error: manually fixing the error and continue?

Asked by Q Liao on 1 Jul 2013

Hi all,

Let's say I toggle on the dbstop if error. And the matlab automatically stops at the error, is it possible for me to manually fix the error and continue the code execution (right from the place where Matlab stops, instead of re-running the code from the beginning)?

Thanks in advance!

Best, Liao

0 Comments

Q Liao

Products

3 Answers

Answer by Jan Simon on 2 Jul 2013
Accepted answer

The documentation of dbstop is clear in this point:

 dbstop if error — Run-time error that occurs outside a try/catch block. You cannot resume execution after an uncaught run-time error. 

1 Comment

Q Liao on 2 Jul 2013

Thanks!

Jan Simon
Answer by Youssef KHMOU on 1 Jul 2013

hi,

Yes, if you put the command dbstop if error at the top of the M-file and run your code, when the compiler finds the error, the cursor indicates the line , then your press "F5", fix the error and re run, repeat the process until the code is error-free .

3 Comments

Q Liao on 1 Jul 2013

Thank you for your answer and sorry for my confusing phrasing. What I want to ask is how to continue code execution right from the place where Matlab stops, instead of re-running the code from the beginning

Youssef KHMOU on 1 Jul 2013

ok

You go to the menu of the M-file page, you click on cell and then enable cell mode , next you divide your code into parts using the notation %% in the beginning and end of each part, then this when a cursor is placed somewhere in specified cell, you click on evaluate cell in top right .

I hope this is clear,

More information can be found in the following page : http://blogs.mathworks.com/community/2009/06/08/using-the-cell-mode-toolbar/

Q Liao on 2 Jul 2013

Thanks!

Youssef  KHMOU
Answer by per isakson on 1 Jul 2013
Edited by per isakson on 1 Jul 2013

AFAIK: The answer is NO. It is not possible.

However,

  1. you can fix the line, but don't save
  2. select the line, right-click and Evaluate Selected (F9) to ensure that the fix works
  3. select lines before and after the fixed line and Evaluate Selected

But eventually you must save and re-run.

1 Comment

Q Liao on 2 Jul 2013

Thanks!

per isakson

Contact us