You can only do this by using the Real Time Workshop running on a target which includes a Real-Time Operating Systems. In any other situation, there are other operations attempting to run at the same time that Matlab is running, making the Matlab run time variable.
Any routine which does not pre-allocate all memory (including that used temporarily) may take an indefinite amount of time to locate available memory. Furthermore, Mathworks does not provide any user-level control over when internal routines such as garbage-collection will be run.
The time taken for any interaction with the operating system or disk I/O is inherently variable with operating systems that are not designed as Real Time Operating Systems (and even then one may have to call special real-time versions of the routines to get real-time response)
MS Windows is not designed as a Real Time Operating System. Some versions of Linux are able to run in real-time modes when specially configured.