"uniques" giving duplicates... Matlab adding a tiny sum?

When I look for the unique values of P in column 1, i get a duplicated 0.975...
Somewhere along the line, Matlab probably decided to add a 1 x 10^-28 to some of the cells or something!
I want the 0.975's to be the same, so that on a graph & legend, I no longer get duplicated lines.
:-)
Cause?
Solution?
Doron
>> PU = unique(P(:,1))
PU = ... 0.7000 0.8000 0.9000 0.9250 0.9500 0.9750 0.9750 1.0000

 採用された回答

Walter Roberson
Walter Roberson 2012 年 2 月 23 日

0 投票

4 件のコメント

Doron
Doron 2012 年 2 月 23 日
...Not this again!
thanks Walter
Walter Roberson
Walter Roberson 2012 年 2 月 23 日
Yup, again ;-) You will get to the point where you don't trust _any_ floating point comparison. Use liberal doses of paranoia in floating point computations.
Sean de Wolski
Sean de Wolski 2012 年 2 月 23 日
We should sell floating point awareness tin foil hats.
Walter Roberson
Walter Roberson 2012 年 2 月 23 日
In some of my earlier incarnations, I had to assume that there might be compiler bugs in the floating point calculations. Not that such bugs were at all *common*, but you wouldn't want to bet someone's safety on the assumption that there were no invisible glitches.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

質問済み:

2012 年 2 月 23 日

編集済み:

2013 年 10 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by