Real Number to N-digit String
Version 1.0.0.0 (1.26 KB) by
Omar
num2strN( input , N )
Floors a real number and converts it to an 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 (2026). 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
Created with
R2009b
Compatible with any release
Platform Compatibility
Windows macOS LinuxCategories
- MATLAB > Language Fundamentals > Data Types > Numeric Types >
- MATLAB > Language Fundamentals > Data Types > Characters and Strings >
Find more on Numeric Types in Help Center and MATLAB Answers
Tags
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.0.0.0 |
