Be the first to rate this file! 6 Downloads (last 30 days) File Size: 1.16 KB File ID: #41520

Insert commas into numbers

by

 

29 Apr 2013 (Updated )

Insert commas into numbers.

| Watch this File

File Information
Description

Insert commas into numbers, e.g. 1234567 -> '1,234,567'.

Required Products MATLAB
MATLAB release MATLAB 7.12 (R2011a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (1)
04 Jun 2013 Jan Simon

A faster loop-free approach wich considers a fractional part also:
S = sprintf('%.16g', pi * 1e12);
S(2, strfind(S, '.') - 4:-3:1) = ',';
S = transpose(S(S ~= char(0)));

Updates
03 Jun 2013

Fixed leading commas

Contact us