Pause MATLAB when running external simulation that writes to file (Scripts) Publisher's description
This simple code handles the problem where MATLAB interfaces with an external program that itself writes to a data file.
This simple code handles the problem where MATLAB interfaces with an external program that itself writes to a data file. The 3-line use of this code is as follows:
(1) call external code (usually via system command)
(2) call sim_runtime(...)
(3) call subsequent statements
The subsequent statements will not be executed until the external program has finished writing to the external file of interest.
The algorithm is simple: MATLAB is stuck in an infinite while loop that checks to see whether the end of file character has changed in the file the external code is writing to. This requires some user knowledge of the external program: both the time taken to open the external file for writing and a rough estimate of the time taken between subsequent writes to that file.
The subsequent statements following sim_runtime(...) in the main MATLAB code can be used to post-process the recently written file, a different file, or do anything else.
System Requirements:No special requirements.
Program Release Status: New Release
Program Install Support: Install and Uninstall