MATLAB: Does the function freeze or hang when I use the bang or exclamation point operator (!) or DOS to invoke a separate process from MATLAB

!alonebangdosexclamationfreezehangMATLAB Compilershellstandstand-alonestandalonesystemunix

Why does my function freeze or hang when I use the bang or exclamation point operator (!) or DOS to invoke a separate process from MATLAB?
When the spawned process or application exits, MATLAB continues to work correctly however MATLAB hangs until the application exits. I observe the same behavior if I compile my function using the MATLAB Compiler.

Best Answer

In general, spawning a separate process should hang MATLAB until the application exits. Some applications automatically background or are automatically backgrounded by the application that spawned them.
The solution to this is to background the spawned application. This may be accomplished by using the DOS application start.exe.
Add the command "start" to the beginning of your DOS call as in:
!start notepad
or
dos('start notepad')