Can you continue with subsequent lines of code while waiting for user input?
조회 수: 5 (최근 30일)
이전 댓글 표시
I know that it isn't possible to run two scripts at once in MATLAB, however I would like to know if it is possible to execute commands in a script while waiting for user input, rather than pausing until an input is given? I have an array of white dots which is gradually changing to become more symmetrical (by deleting half the dots and replacing with reflections (in the vertical midline) of the other half). A certain percentage of the dots are changed, the new image of the array replaces the last one, and the script is paused for 0.01s. This continues for about 20 secs, until all the dots have been replaced (so the array is 100% symmetrical) I want the user to press enter when they think they can see the symmetry, and for the iterations which gradually transform the array (by replacing dots and then pausing) to stop when they press enter.
therefore my first line of code would be
input('press enter when it looks symmetrical')
but I would then want to run through the iterations which make the array look more symmetrical, until user input is given, at which point the iterations should stop. I could then obtain data such as the time it took for the user to recognize the symmetry, or the % of dots which were symmetrically arranged when they did recognize it.
Any suggestions? Can I execute other commands until user input is given?
댓글 수: 0
채택된 답변
Matt J
2014년 8월 25일
편집: Matt J
2014년 8월 25일
I don't know how you're displaying your array. A natural way to do this would be to make a GUI application in GUIDE . You can create a GUI window with a start button to start the evolution process, an axes to display your evolving image, and a stop button for the user to say when the array has evolved enough. The start button callback would run the array evolution process, but you would set its Interruptible property to 'on' and you would write the callback so that it would periodically check the GUI figure window's appdata for a stop flag. The stop button would be used to set this flag, using guidata.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Object Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!