MATLAB: Run code in GUI automatically as soon as it starts

automatic;guiguideinfinite loopopeningfcnstartworkaround

Hi.
I have a GUI that contains an infinite loop for Data handling. My plan is to embed it in the Windows scheduled tasks so that it starts automatically every morning at 4 AM. I have created a button to break the loop when necessary.
Because the program will run on an unmonitored PC, I need the code to start automatically when the GUI starts. However, if I put it in the OpeningFcn, the code executes before the GUI becomes visible, so the GUI does not become visible at all (since it's an infinite loop) and so the button to cancel the loop never appears.
Does anyone have an idea for a workaround?

Best Answer

Put it in the OutputFcn - the GUI will be visible by the time it gets to the OutputFcn, which gets run as soon as the OpeningFcn has finished running.
Related Question