|
"Christopher Kube" <ckube@charter.net> wrote in message <idtpe1$kpf$1@fred.mathworks.com>...
> Hi, I have GUI built that connects with a serial object. The GUI executes a continuous read of the serial object via a while loop. I would like to be able to use the close button (red x) to close the GUI while the while loop is active without an error.
>
> Currently, if I try to close I get the following error:
>
> ??? Operation terminated by user during ==> kube2>disp_temp at 105
>
> In ==> kube2 at 76
> disp_temp(i)
Three ideas. They're in ascending order for better options (in my opinion)
-You could use the status of the GUI figure as your conditional in the while loop so that when the figure no longer exists it stops.
-You could use a flag as your while loop conditional. Have it stored in appdata (getappdata/setappdata) and in the CloseRequestFcn for your GUI, set it to false.
-Instead of using a while loop use a timer object. Then stop the timer directly.
doc timer
|