# How to campare signals with different length?

7 views (last 30 days)
BoWen Han on 27 Apr 2022
Commented: Star Strider on 2 May 2022
Hi
Can someone help me out please? If I have a set of signals with different length. How can I compare them with the reference one and get the similarity or kind of correlation.
For example I have a reference signal with 75 samples. 10 signals with different length between 65 to 80. I would like to use those 10 signals to compare with the reference one by one and see how similar they are.
I know the correlation if I have the signals with the same length but I am confusing about how to do it with the different length signals. I have a roughly idea is make those 10 signals shifting from left to right of reference signal but I dont know which output should I do to compare the similarity.
Best Regards

Star Strider on 27 Apr 2022
One option may be the Signal Processing Toolbox findsignal function (introduced in R2016b). The signal lengths are not important.
The function also produces a third output that is the Euclidean distance between the two signals, so that will be a measure of their similarity.
Star Strider on 2 May 2022
As always, my pleasure!

Jan on 27 Apr 2022
It depends.
You can compare two sine waves, if one has 80 and the other one 75 samples. But how do you define "similarity"? You can shift the phase, interpolate to change the frequency, shift the signal up and down and amplify the values until the curves are matching. But are they more similar, if you have to adjust only the phase or only the amplitude?
How similar are two sin waves, if the second one equals the first one plus some noise?
Before you can implement this in Matlab, you have to define mathematically (or even better physically), what you want to compare. Otherwise the results are arbitrary:
What is the difference between a blackbird? - Both legs have the same length, especially the right one.
BoWen Han on 2 May 2022
Thanks for your help and sorry for late reply. Yeah this is the point I am struggling how to define the 'similarity'. I have some results now but it is hard to say how the result can present similarity.
Thank you