MATLAB Answers

# MATLAB's accuracy of digits number

28 views (last 30 days)
Dias Papas on 22 Jun 2011
Commented: Alexei on 26 Nov 2014
Hi to everyone,
I am dealing with satellite data with accurancy of 25 digits. As I know MATLAB provides computations with maximum 16 digits (long e format). Is there any way to process these data with 25 digits accuracy, because i dont want these values to be rounded?
Thanks a lot
Diamantes
##### 3 CommentsShowHide 2 older comments
the cyclist on 22 Jun 2011
It could be that the each number being sent encode information on more than one variable, with some kind of multiplexing. So, maybe the final digits are not just more precision on the first digits.

Sign in to comment.

### Accepted Answer

the cyclist on 22 Jun 2011
Do you have the Symbolic Math Toolbox? If so, then:
##### 2 CommentsShowHide 1 older comment
Walter Roberson on 22 Jun 2011
If my memory hasn't slipped a bit: the Maple version of the Symbolic Math Toolbox did not have any file input operations; those were, though, exposed by the Extended Symbolic Math Toolbox.
The MuPad version of the Symbolic Math Toolbox does have file input operations: see http://www.mathworks.com/help/toolbox/mupad/quickref/fileIO.html#fileIO
I do not see there any equivalent of fscanf(). On the other hand, when numbers with large numbers of digits are input, those digits are all preserved... though of course if you then do an arithmetic operation on such a number, the result might be in terms of the current Digits setting.

Sign in to comment.

### More Answers (4)

Fangjun Jiang on 22 Jun 2011
This is a really good question. I like it. Look at the following code:
aStr={'1234567890.12345';
'1234567890.123456';
'1234567890.1234567';
'1234567890.12345678';
'1234567890.123456789'};
aNum=cellfun(@str2double,aStr);
aTF=bsxfun(@eq,aNum,aNum')
aTF =
1 0 0 0 0
0 1 0 0 0
0 0 1 1 1
0 0 1 1 1
0 0 1 1 1
bStr={'0.123456789012345';
'0.1234567890123456';
'0.12345678901234567';
'0.123456789012345678';
'0.1234567890123456789'};
bNum=cellfun(@str2double,bStr);
bTF=bsxfun(@eq,bNum,bNum')
bTF =
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 1
0 0 0 1 1
Questions:
1. What is the number of precision that MATLAB double can distinguish, 16, 17 or 18? The first example above shows 17, the second shows 18.
2. What to do if need to read more number of precision.
##### 2 CommentsShowHide 1 older comment
Malcolm Lidierth on 25 Jun 2011
For double precision see http://www.mathworks.com/company/newsletters/news_notes/pdf/Fall96Cleve.pdf
For more digits, you could use java.math.BigDecimal and/or the Apache math BigReals that use them e.g. in MATLAB
java.math.BigDecimal('1').divide(java.math.BigDecimal('3'),10000,java.math.RoundingMode.HALF_EVEN)

Sign in to comment.

Paulo Silva on 22 Jun 2011
The Symbolic Math Toolbox™ can handle the 25 digits, some of their functions have default digit number of 32 digits.
##### 2 CommentsShowHide 1 older comment
Sean de Wolski on 22 Jun 2011
@Fangjun
http://www.mathworks.com/matlabcentral/fileexchange/22239-num2strexact-exact-version-of-num2str
might interest you.

Sign in to comment.

Dias Papas on 25 Jun 2011
Thanks a lot for your answers. My field, which i use such a number of digits, is satellite orbit determination and gravity field modeling. For example ocean's tide's data are given with 25 digits. Yes, this doesnt mean that all of them are totally useful but they are play their role.
Anyway thanks everyone!
Dias
##### 2 CommentsShowHide 1 older comment
Alexei on 26 Nov 2014
Pretty sure that's not what it means. I'm pretty sure the uncertainty principle means that such an adequate position measurement will yield enormous uncertainty in what the impulse is. The impulse could still be really tiny or zero -- but you would have no idea.

Sign in to comment.

Derek O'Connor on 25 Jun 2011
Here is a quotation from Prof Nick Trefethen FRS, Oxford:
11. No physical constants are known to more than around eleven digits, and no truly scientific problem requires computation with much more precision than this.
I'll repeat the question asked by others here: why do you need (or think you need) 25 decimal digits.
Here is a cognate quotation from Trefethen:
6. If the answer is highly sensitive to perturbations, you have probably asked the wrong question.
These quotations (maxims) can be found at:
This Matlab Newsgroup thread may be useful:
##### 2 CommentsShowHide 1 older comment
Derek O'Connor on 28 Jun 2011
Jan,
I don't understand why you need more digits. Why not change the last digit of the 11-digit value and see if there is a large change in the answer?
I do not see a contradiction between Maxim 6 and Maxim 11. They are essentially "orthogonal", i.e., independent. Of course, if a problem is ill-conditioned then many digits may be needed to get an exact answer, which seems to contradict maxim 11. But Maxim 6 says that you should not be solving ill-conditioned problems (except as a hobby, maybe).
See the thread in my answer above and pages 8 to 11 in
http://www.scribd.com/doc/26135665/Two-Simple-Statistical-Calculations-and-ClimateGate

Sign in to comment.

### Community Treasure Hunt

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

Start Hunting!