title: Cross-Correlation and Interpolation to choose the most similar signal
body: <p>I am using Matlab to perform some signal processing and I have a question about <strong>cross-correlation and interpolation</strong> to choose the most similar signal.</p>
  
  <p>Let's say I have two signals K1 and K2, with sampling frequency 30Hz, and a third signal Q, with sampling frequency 100Hz. The first step I perform is <strong>spline interpolation</strong> on the signals K1 and K2 in order to have a sampling frequency of 100Hz. Then, I perform an <strong>amplitude normalization</strong> on all signals so they can be comparable. </p>
  
  <p>So for now, I have three signals with sampling frequency 100Hz and all of them have <strong>different lengths</strong>. Now my main question: in the end I want to choose which signal, K1 or K2, is more similar with Q and I want them to have the same length. I thought on two hypothesis:</p>
  
  <p>1 - I <strong>interpolate</strong> the three signals to the same length and then I perform <strong>cross-correlation</strong> and choose the signal with maximum value of cross-correlation</p>
  
  <p>2 - I perform <strong>cross-correlation</strong>, choose the signal with maximum value of cross-correlation and then I <strong>interpolate</strong> the two signals (the Q and the signal chosen)</p>
  
  <p>My doubt here is that on the first option, when I interpolate the three signals then I will perform cross-correlation with signals with different sampling frequencies but the same length. On the second option, I am performing cross-correlation with signals with the same sampling frequency but different length and then I interpolate.<br>
  I am not sure which is the correct way of doing this or even if it is indifferent. </p>
  
  <p>I am using the functions spline and ppval for the interpolation and the function xcorr for the cross-correlation.</p>