|
From: Walter Roberson on 4 May 2008 14:06 In article <481da7a3$0$90272$14726298(a)news.sunsite.dk>, saneman <ddd(a)sdf.com> wrote: >I have the following loop: >for i=1:10 > > pause; > % do something > >end >Is there someway to terminate the loop when the user presses a key (like >return, escape etc)? If you have a figure you can use a WindowKeyPressFcn callback. If you do not have a figure, then no way is provided within Matlab itself. If you happen to be running under MS Windows then there is a Matlab File Exchange (FEX) contribution that can test for waiting keys. -- "Not the fruit of experience, but experience itself, is the end." -- Walter Pater
From: Romuald Pinheiro on 4 May 2008 15:21 Dude, I had the same problem I think it would be best to anticipate the chance of an infinite loop by putting a delay in the code like this: while x< blah blah blah x(n)= blah*n -blah blah blah n=n+1 pause(0.001) % put this so you have a chance to stop the code when matlab pauses end If the loop is indeed infinite or is taking super long, then you press "ctrl-C" (works on my mac; not sure about windows) and you should regain control of matlab. Hope that helped
|
Pages: 1 Prev: Serial object, accuracy of TimerFcn callback Next: Probability matching |