Format number with a thousands separator of your choice

A function to convert a number to a more readable format by adding thousands separators.
711 Downloads
Updated 23 Jul 2010

View License

A function to convert a number to a more readable format by adding thousands separators.

This very simple function lets you choose the thousands separator character and the number of decimal spaces to return. Any character (including white space) is accepted as a separator. For example

separatethousands( 1234.567, ',' , 1 )

returns string
'1,234.6'

Cite As

Eero Kuusi (2024). Format number with a thousands separator of your choice (https://www.mathworks.com/matlabcentral/fileexchange/28208-format-number-with-a-thousands-separator-of-your-choice), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2008b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Data Type Conversion in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.2.0.0

Cleaned up three lines of code.

1.1.0.0

Fixed problems with negative values and rounding. Changed to accept multiple character separators (char -> string). Changed description example to a cleaner one.

1.0.0.0