Code covered by the BSD License  

Highlights from
Compact data uncertainty format

5.0

5.0 | 1 rating Rate this file 3 Downloads (last 30 days) File Size: 2.8 KB File ID: #10148

Compact data uncertainty format

by Peter Mao

 

25 Feb 2006 (Updated 09 Jun 2006)

given data and uncertainty, this program reformats the number into parenthetic notation.

| Watch this File

File Information
Description

example: reformats '10.3 +- .2' as '10.3(2)'.

usage: >> format_data(10.3,0.2)
        ans = '10.3(2)'

Often, it is more compact to represent the uncertainty of a datum by placing the uncertainty in parentheses with the uncertainty understood to apply to the final digit(s) of the datum. This program achieves such formatting, properly accounting for the decimal point, where applicable. The output can be set in standard decimal, scientific, engineering or metric formats. For scientific or engineering, LaTeX formatting is also an option. The number of digits in the uncertainty is also an option (default = 1). If anyone has better suggestions on the name of this function or the title, please let me know!!

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 (2)
15 Nov 2007 Rolf Heidemann

Very useful.
The input uncertainty of 0 should be treated, e.g as omitting the parentheses.

30 Nov 2007 peter mao

After seeing Rolf's comment, I thought about adding in special handling for sigma==0, but then decided against it.

Consider if the uncertainty was infinitesimally small. Then one would have an enormous number of significant digits. With ZERO uncertainty, then one must report an infinite number of significant digits!

I suggest that Rolf put an if-then around this code to get the result he desires. I don't think it is appropriate to handle that within this code.

Thanks for your comment.

Peter

Please login to add a comment or rating.
Updates
08 Mar 2006

type-o's in description, summary got cut off.

21 Mar 2006

made changes suggested by M-Lint to make it run faster. EXIST specifies 'var' and REGEXP specifies 'once' now.

The HELP section does include examples, despite the code metrics complaint!!

09 Jun 2006

Code updated to properly handle negative numbers.

Tag Activity for this File
Tag Applied By Date/Time
strings Peter Mao 22 Oct 2008 08:16:47
parentheses Peter Mao 01 Feb 2009 16:11:07
confidence interval Peter Mao 01 Feb 2009 16:11:07
format Peter Mao 01 Feb 2009 16:11:07
uncertainty Peter Mao 01 Feb 2009 16:11:07
parenthetical Peter Mao 01 Feb 2009 16:12:42

Contact us at files@mathworks.com