MATLAB: Does the MATLAB application closes unexpectedly when no figure is open

MATLAB

I have written an application consisting of several users interfaces. When one user interface/figure is closed, the visibility of a different figure is set from off to on. This works fine in MATLAB. However in a standalone application the new figure is not shown, the application closes. When opening the application from cmd.exe I see the following message:
Warning: 1 invisible figure(s) exist at MATLAB Runtime termination. The figure ID's of the remaining figures are:
If your application has terminated unexpectedly, please note that applications generated by the MATLAB Compiler terminate when there are no visible figure windows.
See documentation on how Standalone applications terminate for more information.

Best Answer

A standalone application ends when the end of the main function is reached or when there is no visible figure anymore. Since you close a figure before making the next figure visible, the standalone application ends. This behavior is intended. There are two ways you can ensure that the next GUI/figure is shown:
- Have some code running that runs till the next figure is set to visible
- Set the new figure to visible just before/while the original figure is closed