The Embedded Real-Time target generates ANSI/ISO C, C++, and encapsulated C++ code with floating-point and fixed-point data for efficient real-time execution on virtually any production processor. If you generate your code with the 'ert.tlc' target file, your generated C code will by ANSI compliant. Please refer to the following link for more information.
Two things happen when MATLAB returns back to the command line:
Memory leaked by any mex files is cleaned up (mxMalloc... or MATLAB arrays). The best practice is to only rely on automatic clean up in the event of an error.
Any pending display/graphics messages are processed by MATLAB. This can be forced by adding a drawnow to your code. In general this should not cause an issue because there should not be a huge number of events pending but there have been bugs in the distant past.
Best Answer