Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



Re: Precision problem with xlsread
Posted:
Feb 19, 2013 10:12 AM


"Qian Ma" <mqpaul@live.cn> wrote in message news:kftmbe$kgh$1@newscl01ah.mathworks.com... > "Marat Mamat" wrote in message <hhq09c$ibs$1@fred.mathworks.com>... >> I have data such as this in an excel sheet. The number of rows and >> columns can get get bigger (few hundreds). 0.000000000000 >> 363.548604178313 485.186546083050 >> 363.548604178313 0.000000000000 202.195421560430 >> 485.186546083050 202.195421560430 0.000000000000 >> 891.253733175912 535.522317088653 539.651284812702 >> 1026.191509271050 673.810725723478 677.908273588691 >> >> I want process this and for that it needs to be in a matrix with the >> format and precision preserved. I tried the Import Data GUI utility, >> which appears to gives me result to 4 decimal places (but when I copy the >> cell the entire value is present). >> >> I tried xlsread('file.xls'). Below is what I get: >> 1.0e+003 * >> >> 0 0.3635 0.4852 >> 0.3635 0 0.2022 0.4852 0.2022 0 0.8913 >> 0.5355 0.5397 >> 1.0262 0.6738 0.6779 >> >> I a previous post on xlswrite, >> http://www.mathworks.com/matlabcentral/newsreader/view_thread/267281 a >> similar problem which wrongly placed decimal point is mentioned. But I >> don't know how to solve this. I also tried to convert to csv format >> first, but the same problem persists. How do I use num2str to solve this? >> Or can it be used? > > REPLY FROM QIAN: > Hi, Marat, > > I think I found a solution for your problem. Before writing the command > "xlsread", you can first input "format long", and then do the "xlsread". > This will import as many as 16 digits from your excel file.
XLSREAD will read the data stored in your Excel file to full precision (since I don't believe Excel has a 128bit integer format or quad precision floatingpoint or anything like that) regardless of the FORMAT setting. All "format long" does is control how the data is _displayed_ in the Command Window; it has no effect whatsoever on how the data is actually _stored._
 Steve Lord slord@mathworks.com To contact Technical Support use the Contact Us link on http://www.mathworks.com



