MATLAB: Is there a function in MATLAB 7.6 (R2008a) that can comma separate the numbers

bankcommacurrencyformatMATLABseparate

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?

Best Answer

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