Real Number to N-digit String
Floors a real number and converts it to an N-digit string, e.g. for N=3 input 1 becomes 001, 34 becomes 034 and 876 remains the same.
Can be used for various purposes. I wrote it for writing images in a folder such that they have names image001.jpg, image002.jpg, etc. I also used it to display the time in an MM:SS format:
tic
your_code
toc = timeElapsed;
[num2strN(round(timeElapsed/60),3) ':' num2strN(mod(timeElapsed,60),2)]
Cite As
Omar (2024). Real Number to N-digit String (https://www.mathworks.com/matlabcentral/fileexchange/28035-real-number-to-n-digit-string), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- MATLAB > Language Fundamentals > Data Types > Numeric Types >
- MATLAB > Language Fundamentals > Data Types > Characters and Strings >
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.0 |