Why does Matlab execute my code sometimes twice?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Sometimes when I press the run button in the Editor, the code is executed twice (or even more times). I can't exactly define when it happens, but it happened even to this very simple program code:
clear all
for z=1:5
z
pause(1)
end
Have you experienced similar problems? Any idea why it can happen?
8 Kommentare
Image Analyst
am 7 Aug. 2021
@Alvin Stroyny, then same answer. Either you are calling it recursively or clicking the button twice. Maybe your keyboard is not being properly debounced - try a new one. Or try putting a breakpoint there.
John D'Errico
am 7 Aug. 2021
Bearbeitet: John D'Errico
am 7 Aug. 2021
Since this happens after a mouse click, I might check to see if you have some issue with your mouse. For example, swap a different mouse in. Or, see if it also repeats when using the run command directly, since you can run a script from the command line.
Antworten (1)
Image Analyst
am 24 Sep. 2013
Most likely, you clicked on the green "Run" triangle twice, or you typed F5 twice. Either of those will cause it to run once, then immediately run again after it finished (I actually tried it).
2 Kommentare
Image Analyst
am 24 Sep. 2013
Step through it one line at a time and see where it goes after you reach the end of the code.
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!