フィルターのクリア

How can I measure similarity between two signals with different lengths (and with different time points)?

42 ビュー (過去 30 日間)
Hi all,
I want to measure similarity between two signals with different lengths.
Following is my code.
A = [1.2,1.5;
2.4,0.5;
3.2,1.5;
4.1,1]
B = [1,1;
2,0;
3,1;
4,0.5;
5,1.5]
BB = [1,1;
2,0;
3,1;
4,0.5;
5,1.5]
C = [1.1,1.2;
2.2,1.3;
3.3,1.5;
4.2,1.7]
%%%%% B and BB are the same signal
plot(A(:,1), A(:,2)) % first column is the x-values
hold on;
plot(B(:,1), B(:,2))
figure(2)
plot(C(:,1), C(:,2)) % first column is the x-values
hold on;
plot(BB(:,1), BB(:,2))
%%% Similarity between B and A
B=imresize(B, size(A))
r_BA = corr2(B,A) % Correlation between B and A
maxB = max(B)
maxA = max(A)
nor_B = bsxfun(@rdivide,B,max(B))
nor_A = bsxfun(@rdivide,A,max(A))
nor_r_BA = corr2(nor_A, nor_B) % Normalized Correlation
%%% Similarity between B and C
BB=imresize(BB, size(C))
r_BBC = corr2(BB,C) % Correlation between BB and C
maxBB = max(BB)
maxC = max(C)
nor_BB = bsxfun(@rdivide,BB,max(BB))
nor_C = bsxfun(@rdivide,C,max(C))
nor_r_BBC = corr2(nor_A, nor_BB) % Normalized Correlation
%plot between B and A
Plot between B and C
It looks like B and A have higher similarity than B and C.
However, the correlation (corr2) value between B and C is greater than B and A.
Normalized correlation values are the same for both.
Please let me know how I can measure similarity of the 2 signals above?
I can accommodate R, SPSS or any other tool to solve this problem.

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 3 月 9 日
編集済み: Ameer Hamza 2020 年 3 月 9 日
If you plot the signals after applying imresize you will see that A and B are not very similar to each other. It appears from the discussion on different forums, there is no universal way to address the issue of correlation between vectors of unequal length. The most appropriate strategy seems to be getting rid of extra data from signals to make them of equal length.
  15 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 3 月 14 日
Glad to be of help. Best of luck with your work.
SOPAE YI
SOPAE YI 2020 年 3 月 16 日
Mr. Hamza,
You've been such a great help!!
I am very much appreciative of your sharing your expertise, sir.
Stay healthy and happy!!!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCorrelation and Convolution についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by