bytes of double may be aren't sufficient!

4 views (last 30 days)
Srikar Chinam
Srikar Chinam on 6 Apr 2015
Edited: Stephen23 on 6 Apr 2015
200201382 is getting converted to 200200000 as it is received by matlab as 2.002e+08. I need it to be as 200201382 itself an need matlab to input it as 200201382. How can I do this? Thank you in advance.

Answers (2)

John D'Errico
John D'Errico on 6 Apr 2015
Edited: John D'Errico on 6 Apr 2015
I think you need to learn about the format command. That it is DISPLAYED on the command line as such is not relevant.
The range of a double is entirely adequate for that number. It is stored properly. You simply don't know that it is.
help format
format long g
A common problem is when you have many numbers of different magnitudes in a vector or array. Then MATLAB will choose to use a scientific notation for the display, with limited number of digits displayed.
v = [.0001;200201382]
v =
1.0000e-04
2.0020e+08
As you can see, it LOOKS like the second element of v was not stored properly. However, MATLAB knows what it is.
v(2)
ans =
200201382

Srikar Chinam
Srikar Chinam on 6 Apr 2015
i'll be more specific. The text file I have has millions of numbers like 200201382 in a column i.e.,
200201382 200201383 200201384 200201385 . . .
When i'm trying to import this data, matlab is converting 200201382 to 200200000
Please have a look at the attached screenshot
  4 Comments
Image Analyst
Image Analyst on 6 Apr 2015
Please attach the data file - just the first few lines, not the whole thing.
John D'Errico
John D'Errico on 6 Apr 2015
Edited: John D'Errico on 6 Apr 2015
How are you reading it in? While you SAY that you will be specific, so far, we have seen only hints of what you are doing. Making us guess?

Sign in to comment.

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!