MATLAB: How to measure similarity between two signals with different lengths (and with different time points)

measuring similarity between two signals

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.

Best Answer

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.