Going to previous step while debugging

Hi
How to go to previous step while debugging in matlab just like we use F10 for next step? Is there any such option?
Thanks - Lalan

 采纳的回答

Guillaume
Guillaume 2015-5-12
You would think it would be something easy to implement in a interpreted language, but unfortunately, it's not possible to move the execution pointer to an arbitrary line in matlab.
You can only step forward I'm afraid.

5 个评论

One step back could require restoring a lot of state if going back was intended to mean "undo".
Well Visual Studio can do it in compiled languages. There is no state undo, just a repositioning of the EP. It's still incredibly useful when you want to replay something that didn't behave as you expected.
Admittedly, Visual Studio is the gold standard of programming environment, but I'm always disappointed by the limited editing and debugging facilities of matlab which only target one language.
I copy and paste sections of the line into the command window to figure out what was going on. Presuming that is that going back doesn't involve a change of control such as wanting to not terminate a loop that was just popped out of.
Actually, what I really miss is the ability to skip (as in not execute) a line.
I just came across this today debugging some code, arrived on a line which contained a typo (wrong variable name). I could just have typed the correct instruction in the command window and skipped to the next line instead of restarting the debugging from scratch.
It's the same concept though: give the user the ability to move the execution pointer around.
This capability is called "edit and continue". I love it in Visual Studio and am frustrated it's not there in MATLAB. I use Walter's method of doing/undoing stuff in the command window while at a breakpoint.

请先登录,再进行评论。

更多回答(1 个)

Not sure if it will help you since i don't know why you need to go back, but have a look at conditional breakpoints. This helped me a lot in the cases where i wanted to go back one step in debugging.

1 个评论

Thanks Hoek for the answer. I felt this necessity here. While debugging a program, I accidentally crossed a function where I needed to go inside that function. So I wanted to come back to previous step and step into that function.

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by