Error with Uniquetol: " Repetitive numbers not being removed"

1 回表示 (過去 30 日間)
Chris Dan
Chris Dan 2020 年 7 月 19 日
コメント済み: Chris Dan 2020 年 7 月 19 日
Hi,
I have this double array by the name " GlobalNMesh", I am attaching the file.
It has some repetitive numbers, as shown
I am using
load('GlobalNMesh.mat')
c = uniquetol(GlobalNMesh)
But I am not getting correct results, repetitive numbers are not being removed...
Does anybody know what changes to make?

採用された回答

Stephen23
Stephen23 2020 年 7 月 19 日
Set the tolerance to a suitable value, e.g.:
>> uniquetol(GlobalNMesh,1e-3)
ans =
0 0.0336 0.1199 0.1331
  2 件のコメント
Bruno Luong
Bruno Luong 2020 年 7 月 19 日
Or simply display more digits to see they are actually not identical
Chris Dan
Chris Dan 2020 年 7 月 19 日
Thanks :)

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

その他の回答 (1 件)

dpb
dpb 2020 年 7 月 19 日
Yeah, fix the magnitude of the tolerance interval you want distinguished--by default uniquetol(A) uses 1e-6 for single-precision inputs and 1e-12 for double-precision inputs.
Your values are different only in the 5th/6th position so need a tolerance to reflect that...
>> format long, format compact
>> diff(GlobalNMesh)
ans =
0.033640000000000 0.086250000000000 0.000010000000000 0.013160000000000 0.000040000000000
>> fix(log10(diff(GlobalNMesh)))
ans =
-1 -1 -4 -1 -4
>> uniquetol(GlobalNMesh,1E-4,'DataScale',1)
ans =
0 0.033640000000000 0.119890000000000 0.133060000000000
>>

カテゴリ

Help Center および File ExchangeDescriptive Statistics and Visualization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by