# Correlation between two graphs in Matlab

I am trying to make a system that detects footsteps. First I filter and decimate the original signal, then I make a convolution between the filtered signal and a single footstep, then I extract the envelope (here I have a threshold of 1 and if the peaks exceed this threshold then it means that those are footsteps). The problem is that the plots (envelope and footsteps) need to be correlated, but the footsteps are right shifted and I really don't know which might be the cause. I hope you can help me. I'll show you an example of two different signals.

Example 1: Example 2: Edit:

convolutie=conv(filtrare2,sample);
t=(0:length(convolutie)-1)/Fs;
axes(handles.semnalConv);
plot(t,convolutie);xlabel('Time(s)');

y = hilbert(convolutie);
env = abs(y);
t=(0:length(env)-1)/Fs;
axes(handles.semnalAnvelopa);
plot(t,env);xlabel('Time(s)');

[pks,locs]=findpeaks(env,'MinPeakHeight',1,'MinPeakDistance',100);
axes(handles.semnalPasi);
stem(locs.*10,pks.^(1/2)/4,'r');


The problem was that there was a different number of samples at each plot.

• Try xcov or xcorr – A. Donda May 7 '15 at 16:45
• I'm sorry for asking but where should I use xcov? (I'm a beginner at matlab and I only want the stem plot match the envelope plot). I tried using xcov instead of conv(x,y) but the result is not good. I will edit my post and add a part of my code so you can see what I did there. – Amalia May 7 '15 at 18:24
• Those function are ways to compare two time series at multiple lags. This way you could find the lag at which your wav matches your footstep data best. – A. Donda May 7 '15 at 18:38
• Can you upload your data? – A. Donda May 7 '15 at 18:39
• It seems I figured it out. The problem was that there was a different number of samples at each plot. Anyway, thank you! – Amalia May 7 '15 at 21:20