How can I calculate percentage of Euclidean distance?

37 ビュー (過去 30 日間)
wisam kh
wisam kh 2018 年 8 月 15 日
コメント済み: OCDER 2018 年 8 月 16 日
Hello
I use this code to find the similarities between features by the Euclidean distance.
function D= E_distance(n1, n2)
D = sqrt(sum((n1 - n2) .^ 2));
end
It will give me the distance between features, but I want to get the percentage where I can compare it to the threshold, how can I get it?

採用された回答

OCDER
OCDER 2018 年 8 月 15 日
編集済み: OCDER 2018 年 8 月 16 日
Assuming you want similarity % as explained here, alter the equation as such : https://stats.stackexchange.com/questions/53068/euclidean-distance-score-and-similarity
function S = E_similarity(n1, n2)
S = 1/(1+sqrt(sum((n1 - n2) .^ 2)));
end
If S == 1 (or distance is 0), then two points are the same
If S == 0 (or distance goes to infinite), then two points are very different
To use a cutoff of similarity, for instance 0.80, then you would so this
SimCutoff = 0.8;
if E_Similarity(n1, n2) <= SimCutoff
disp('Exceed cutoff. Not similar enough')
else
disp('Similar enough')
end
  2 件のコメント
wisam kh
wisam kh 2018 年 8 月 16 日
編集済み: wisam kh 2018 年 8 月 16 日
Thank you so much
It works wonderfully.
OCDER
OCDER 2018 年 8 月 16 日
You're welcome!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFeature Detection and Extraction についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by