Compare two vectors for similarity

407 ビュー (過去 30 日間)
Souparno Bandyopadhyay
Souparno Bandyopadhyay 2012 年 12 月 9 日
コメント済み: maxanto 2022 年 2 月 2 日
How to compare two vectors quickly. Right now I print out each in a loop and examine them by eye, is there a way i can find if two are almost similar.
  2 件のコメント
Souparno Bandyopadhyay
Souparno Bandyopadhyay 2012 年 12 月 9 日
I am comparing A to B and then A to C, I need a single number that will allow me to quickly judge A resembles B or C.
maxanto
maxanto 2022 年 2 月 2 日
isequal(a, b)
Returns true if each element of vector a is equal to each element of vector b. If some element of a are different from b returns false.

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

採用された回答

Matt Fig
Matt Fig 2012 年 12 月 9 日
What is the criteria for 'almost similar' in your application? 90% same exact values? 90% of the values in one vector within 95% of some other value in the other vector? Do the values have to be in the same positions? Do the vectors have to be the same length? Perhaps a few short examples would help...
  5 件のコメント
Jan
Jan 2012 年 12 月 9 日
@Souparno: Accepting an answer means that the problem is solved. Is this true here?
Souparno Bandyopadhyay
Souparno Bandyopadhyay 2012 年 12 月 10 日
yes, S = sum(A-B), is what I was looking for.

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

その他の回答 (1 件)

Greg Heath
Greg Heath 2012 年 12 月 10 日
S = sum(A-B) is NOT a useful function for quantifying similarity because positive and negative terms will cancel.
The most common are
mae(A-B) % mean(abs(A-B))
sae(A-B) % sum(abs(A-B))
norm(A-B,1) % sum(abs(A-B))
norm(A-B,inf) % max(abs(A-B))
mse(A-B) % mean((A-B).^2)
sse(A-B) % sum((A-B).^2)
norm(A-B) % sqrt(sse(A-B))
Hope this helps.
Thank you for formally accepting my answer
Greg

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by