Code covered by the BSD License  

Highlights from
num2money

3.5

3.5 | 2 ratings Rate this file 0 Downloads (last 30 days) File Size: 1.66 KB File ID: #19431

num2money

by Kenneth Eaton

 

02 Apr 2008 (Updated 03 Apr 2008)

Converts a numeric value to a monetary value string

| Watch this File

File Information
Description

A simple utility to create a monetary value string representation of a number.

Examples:

   num2money(200) returns '$200'
   num2money(200,'cents') returns '$200.00'
   num2money(-200.34) returns '-$200.34'
   num2money(2000.34) returns '$2,000.34'
   num2money(20000.1023) returns '$20,000.10'

MATLAB release MATLAB 7.1.0 (R14SP3)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
03 Apr 2008 John D'Errico

I imagine this might be useful to some. Good help, with examples. Its got error checks.

A couple of points though. This is misnamed. num2money implies to me that it should be able to handle euros, pesos, yuan, etc. Any kind of money. The output of this is only dollars, which is a bit biased. num2dollars would have been an appropriate name.

The centsflag argument will default to returning the cents, but the help does not state that there is a default, nor what is the default.

03 Apr 2008 Joseph nonereally

Have yet to get a penny from this program. When will you be mailing the checks?

03 Apr 2008 Kenneth Eaton

Joseph,
  Sorry if you thought this was a Matlab ATM. No cha-ching!

John,
  Good point about the name. I think I'll update it with an extra option to specify the currency. The centsFlag argument is discussed in the help header with the .m file... I just didn't add it to the above description.

04 Apr 2008 Dimitri Shvorob

Inefficient: a single sprintf format takes care of each of the two cases (cents/no cents). An appealing effort, though.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
double money string Kenneth Eaton 22 Oct 2008 09:56:16

Contact us at files@mathworks.com