Pause MATLAB when running external simulation that writes to file

Version 1.0.0.0 (2.24 KB) by Steven
Prevents MATLAB executing subsequent statement after an external program is called.
182 Downloads
Updated 2 Feb 2012

View License

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.

Cite As

Steven (2024). Pause MATLAB when running external simulation that writes to file (https://www.mathworks.com/matlabcentral/fileexchange/34895-pause-matlab-when-running-external-simulation-that-writes-to-file), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2009b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Debugging and Analysis in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0