Is there a function in MATLAB 7.6 (R2008a) that can comma separate my numbers?

1 view (last 30 days)
I would like to have my numbers in MATLAB to be comma separated similar to currency values. For example instead of displaying
num =
2000
I would like to have it displayed as follows
num =
2,000
Is there a function in MATLAB that can provide this format?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 2 Dec 2011
There is no function in MATLAB that will provide this format. However, you can write your own M-function that can provide this feature. An example M-function COMMASEPARATOR.M is attached that will format the number to be comma separated. However, the function only works for integer inputs and will need to be modified if used for doubles.
For example,
num = commaseparator(2000);
will return a string representation of the integer 2000 with a comma in the desired location:
num =
2,000

More Answers (0)

Products


Release

R2008a

Community Treasure Hunt

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

Start Hunting!