HI,
I have data file as .txt
example is :
-0.03541 -0.010
-0.03540 -0.010
-0.03539 -0.018
-0.03538 -0.016
-0.03537 -0.012
-0.03536 -0.006
-0.03535 -0.004
-0.03534 -0.006
-0.03533 -0.004
-0.03532 -0.010
i am using load('filename') or import
to load data into matlab.
i want to get original data but what i am getting is:
rounded data? as -0.03541 changed to -0.0354
"muzaffar " <muzaffarbashir@yahoo.com> wrote in message
<g3fnmq$r1g$1@fred.mathworks.com>...
> HI,
> I have data file as .txt
> example is :
> -0.03541 -0.010
> -0.03540 -0.010
> -0.03539 -0.018
> -0.03538 -0.016
> -0.03537 -0.012
> -0.03536 -0.006
> -0.03535 -0.004
> -0.03534 -0.006
> -0.03533 -0.004
> -0.03532 -0.010
> i am using load('filename') or import
> to load data into matlab.
> i want to get original data but what i am getting is:
> rounded data? as -0.03541 changed to -0.0354
>
> regards.
>
The numbers are only displayed like this, but are stored to
a greater precision. See
Hi,
I'm very interested in this subject because I have somehow
the same issue. I have to plot curves with very high
precision and sometimes with thousands of points.
Here the original data:
1.00000000000000000E9 -8.00701165051183317E-2
2.00000000000000000E9 -3.02971825312652543E-1
3.00000000000000000E9 -7.09413944479449832E-1
4.00000000000000000E9 -1.47311413404920044E0
5.00000000000000000E9 -3.14280669618702335E0
6.00000000000000000E9 -7.74340393443416630E0
7.00000000000000000E9 -2.32294512732106240E1
8.00000000000000000E9 -7.08260945830919653E0
9.00000000000000000E9 -3.50965281491944214E0
1.00000000000000000E10 -2.20389981679428093E0
1.10000000000000009E10 -1.64602942145812925E0
Here is what matlab seems to keep:
1e+09 -0.0801
2e+09 -0.303
3e+09 -0.709
4e+09 -1.47
5e+09 -3.14
6e+09 -7.74
7e+09 -23.2
8e+09 -7.08
9e+09 -3.51
1e+10 -2.2
1.1e+10 -1.65
In that case I only have 10 points and the difference
between 2 consecutive points is large, but when I work with
cadence (EDA software) I work with several thousands of
points (1e3 - 1e4) and the difference between 2 consecutive
points can be around 1e-6 to 1e-9 (V or A).
I really doubt that Matlab keep a higher precision and I
would like to know how we could import with higher
precision. Matlab is such an awesome tool...
> Hi,
> I'm very interested in this subject because I have somehow
> the same issue. I have to plot curves with very high
> precision and sometimes with thousands of points.
>
> Here the original data:
> 1.00000000000000000E9 -8.00701165051183317E-2
> 2.00000000000000000E9 -3.02971825312652543E-1
> 3.00000000000000000E9 -7.09413944479449832E-1
> 4.00000000000000000E9 -1.47311413404920044E0
> 5.00000000000000000E9 -3.14280669618702335E0
> 6.00000000000000000E9 -7.74340393443416630E0
> 7.00000000000000000E9 -2.32294512732106240E1
> 8.00000000000000000E9 -7.08260945830919653E0
> 9.00000000000000000E9 -3.50965281491944214E0
> 1.00000000000000000E10 -2.20389981679428093E0
> 1.10000000000000009E10 -1.64602942145812925E0
>
> Here is what matlab seems to keep:
> 1e+09 -0.0801
> 2e+09 -0.303
> 3e+09 -0.709
> 4e+09 -1.47
> 5e+09 -3.14
> 6e+09 -7.74
> 7e+09 -23.2
> 8e+09 -7.08
> 9e+09 -3.51
> 1e+10 -2.2
> 1.1e+10 -1.65
[snip]
> I really doubt that Matlab keep a higher precision and I
> would like to know how we could import with higher
> precision. Matlab is such an awesome tool...
So you are looking for proof that MATLAB "keeps a higher precision"?
Start with "format long", and if that's not enough, use
sprintf('%.20f', value)
to make MATLAB print "value" out to 20 decimal places.
In article <muyprp45poc.fsf@G99-Boettcher.llan.ll.mit.edu>,
Peter Boettcher <boettcher@ll.mit.edu> wrote:
>"Olivier " <m.olivier.lemaire@gmail.com> writes:
>> Here the original data:
>> 1.00000000000000000E9 -8.00701165051183317E-2
>> 2.00000000000000000E9 -3.02971825312652543E-1
>> 3.00000000000000000E9 -7.09413944479449832E-1
>> Here is what matlab seems to keep:
>> 1e+09 -0.0801
>> 2e+09 -0.303
>> 3e+09 -0.709
>> I really doubt that Matlab keep a higher precision and I
>> would like to know how we could import with higher
>> precision.
>So you are looking for proof that MATLAB "keeps a higher precision"?
>Start with "format long", and if that's not enough, use
>sprintf('%.20f', value)
And change the way you export the data. If you are using
save -ascii then use save -ascii -double .
If you are using csvwrite() then instead use dlmwrite() and specify
a Precision parameter. If you are using fprintf() with a %f
format, use a %g format instead and use a wider width, such as %.17g
Note: Matlab is not able to preserve the full precision of
-8.00701165051183317E-2; the closest it can get is
-0.0800701165051183327836525904785958118736743927001953125
which disagrees with the last 2 digits of the original.
The floating point standards give you about 16 digits of precision;
your original data has 18 digits of precision.
--
"No sincere artist was ever completely satisfied with his labour."
-- Walter J. Phillips
Peter Boettcher <boettcher@ll.mit.edu> wrote in message
<muyprp45poc.fsf@G99-Boettcher.llan.ll.mit.edu>...
> "Olivier " <m.olivier.lemaire@gmail.com> writes:
I don't try to prove anything, I just try to use a tool I
appreciate.
Well, I tried the following:
>> format long
>> datadlm = dlmread('sParamToxOrderedDataSet.txt', '\t', 1,0);
>> datadlm
If I ask this question it's first, because I really want to
know how to have high precision data import, and second
because I know a bunch of people around me that have the
same issue (Pr., student....).
"Olivier " <m.olivier.lemaire@gmail.com> wrote in message
<g684i1$o5l$1@fred.mathworks.com>...
> Peter Boettcher <boettcher@ll.mit.edu> wrote in message
> <muyprp45poc.fsf@G99-Boettcher.llan.ll.mit.edu>...
> > "Olivier " <m.olivier.lemaire@gmail.com> writes:
>
> I don't try to prove anything, I just try to use a tool I
> appreciate.
>
> Well, I tried the following:
> >> format long
> >> datadlm = dlmread('sParamToxOrderedDataSet.txt', '\t',
1,0);
> >> datadlm
>
> >> datadlm(:,1), datadlm(:,5)
>
> ans =
>
> 1.0e+10 *
>
> 0.100000000000000
> 0.200000000000000
> 0.300000000000000
> 0.400000000000000
> 0.500000000000000
> 0.600000000000000
> 0.700000000000000
> 0.800000000000000
> 0.900000000000000
> 1.000000000000000
> 1.100000000000000
>
>
> ans =
>
> -0.080100000000000
> -0.303000000000000
> -0.709000000000000
> -1.470000000000000
> -3.140000000000000
> -7.740000000000000
> -23.199999999999999
> -7.080000000000000
> -3.510000000000000
> -2.200000000000000
> -1.650000000000000
Don't *display* data having different scales together (your
first and second colum). MATLAB scaled them together (here
is 10^10, observe the scale right after the "=" sign), and
truncates the output when *display*.
Do rather the following:
- Display each data separately
>> datadlm(10,5) % I let you discover the result
Or better still: Use fprintf
>
> If I ask this question it's first, because I really want to
> know how to have high precision data import,
It's as high as the IEEE 64 bits precision, about
2^(-52), or 2.2 x 10-16 or better than 15 digits.
> and second
> because I know a bunch of people around me that have the
> same issue (Pr., student....).
>
Yes it's quite confusing. All you need to remember is binary
data storing in the computer memory do not use at all the
same storage structure then when it displayed on the screen
or written in an ascii file. So be careful when interpret them.
> well, I guess I made a mistake...
>>> format long
>>> datadlm = dlmread('sParamToxOrderedDataSet.txt', '\t', 1,0);
>>> datadlm(10,5)
>
> ans =
>
> -2.203899816800000
>
> I do apologize if I seemed kind of impudent.
>
> Thank you to all of you for your precious help.
That's not impudence! We were just trying to understand what your
problem was, or what help you were seeking!
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.