Read elapsed time from executables
timeElapsed = etoc
timeElapsed = etoc     return time since start of executable or mex file. In an executable, this function returns the time since the executable has started. In a mex file, this function returns the time since the MATLAB session has started.
This function is supported for code generation. It is designed for desktop deployment of a mex (.mex) or executable (.exe) file. It can not be placed in a MATLAB Function block. For use in Simulink, use the Soft Real-Time block.
Running a MATLAB Executable File (mex) in Soft Real-Time
First, run the function ScheduleEticMatlabExample which prints to the MATLAB Command Window every 0.5 seconds. This function uses etic and etoc to schedule the printing.
Then, run the script buildMatlabSoftRealTimeExample which generates a mex file from ScheduleEticMatlabExample. Since etic and etoc are supported for code generation, the generated mex file ScheduleMatlabExample_mex prints to the MATLAB Command Window every 0.5 seconds.