Elapsed Time as a String (.mlx and .m files)
The use of tic and elapsedTime=toc; commands gives the elapsed time in seconds. This function takes that value (or any other numeric or duration array value, provided it is in seconds) as input and accurately splits it into hours, minutes and seconds, and returns a formatted string that can be displayed on screen or inserted into a file. The formatted string is case dependent. For instance, if the input is 61 (seconds), the output is '1 minute and 1 second', while for an input of 3601 (seconds), the output is '1 hour and 1 second'.
Cite As
K Vijayanth Reddy (2025). Elapsed Time as a String (.mlx and .m files) (https://se.mathworks.com/matlabcentral/fileexchange/72152-elapsed-time-as-a-string-mlx-and-m-files), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.0.0 |
