Shortcut for previous line of code during a loop?
Show older comments
Hello,
Is there a MATLAB shortcut to jump to a previous line of code while in a loop, when working in the command window?
I'm looking for something similar to a CTRL+C for a break while in a loop, except instead of a break, the "code flow" jumps up to the previous line. I would like to do this in case I input an incorrect value or string into the command window while deep inside a loop. It's a tedious process of what I'm doing, so I'm trying to minimize user input. So I do not want to have a "Is this entry correct?" error control for every input.
To rephrase: Instead of having to break the loop/script when I input an incorrect string or value, I would like to know if there is a simple MATLAB shortcut (CTRL+...) that can jump up to the previous line while inside a loop.
Thanks!
Accepted Answer
More Answers (1)
Sean de Wolski
on 20 Dec 2011
1 vote
No. There is not.
A workaround is to put all of this in a function which prompts you each time, but stores the old variable for a few more iterations in case you decide it was bad. Then you could have a push button or something clear it. I would recommend doing this inside a GUI and perhaps have a textbox/listbox/uitable showing the past few values.
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!