How to completely overlap or align two different signals in matlab?

27 views (last 30 days)
Currently i am working on pedestrian step detection (accelerometer data). I used butterworth bandpass filter for my acceleration data to smooth. I have calculated some statistical features like mean,std, variance etc using window size=10 samples and with 50% overlap to previous window. Now i want to overlap/ align both filtered and mean, std or variance signal for obervation/analysis. When i overlap them there is time delay or probably it has time synchonoization issue. I need guidance, how can overlap them or if there is any code to do. Below i am posting my output image of two signals and code used for filtration.I also attached ACC.txt file of some dummy data, diff from the above data, but also having same delay issue. The output image i put here is consist of filtered signal and Std signal. Looking for the kind response. Thanks
Fs=200;
N = 2;
f_low = 0.3;
f_high = 3;
Wn = 2*[f_low f_high]/Fs;
[B,A] = butter(N,Wn, 'bandpass');
% apply band pass filter to data
%norm is input signal
Data_filtered = filtfilt(B,A,norm);
figure;
plot(IMU_ULISS.time(:),norm,'b',IMU_ULISS.time(:),Data_filtered,'r');
hold on
title(['Butter Bandpass Filter']);
legend( 'Norm', 'Data Filtered')
xlabel('Time (sec)');
ylabel('Norm of Acceleration (m/s^2)');
  5 Comments
Muhammad Hammad Malik
Muhammad Hammad Malik on 15 Feb 2021
@Paul Hoffrichter below i am adding the code i used to load the file. I have calculated some statistical features like mean,std, variance etc using window size=10 samples and with 50% overlap to previous window. Now i want to overlap/ align both filtered and mean, std or variance signal for obervation/analysis. When i overlap them there is time delay or probably it has time synchonoization issue, as i shown in my posts
ACC1 = importdata('C:/Users/malik/Documents/03-01-2021/18-01-03-058/GYRO.txt',',');
ACC=ACC1.data;
Time = ACC(:,1);
ACCx = ACC(:,2);
ACCy=ACC(:,3);
ACCz=ACC(:,4);
plot(ACCx, 'r')
hold on
plot(ACCy, 'g')
plot(ACCz,'b')
hold off
title(['combined ACC']);
legend('ACCx', 'ACCy', 'ACCz')
xlabel('Time (sec)');
ylabel('ACC');
Paul Hoffrichter
Paul Hoffrichter on 15 Feb 2021
Edited: Paul Hoffrichter on 15 Feb 2021
These plots do not appear to be the ones that are shown in the OP. In the OP, the data appears to be highly correlated. But with the ACC.txt data, each region has a different correlation. It looks like norm and IMU_ULISS are the two items needed to run the code in the OP, so could you provide that.
The xcorr in fig-110 is poor, so not surprising that finddelay produces poor results.
delay_xy = 7 delay_xz = -5912 delay_yz = 15
For fig-200, 210, I did this to get a better correlation:
ACCx = ACCx + 15;
ACCy = ACCy + 10;
ACCz = ACCz + 5;
The xcorr in fig-210 is still not very sharp, so finddelay still is not very good.
delay_xy = -46 delay_xz = 3 delay_yz = 13
Could you provide the code and the data that produces the figures in the OP.
Is IMU_ULISS a timetable? Working with timetables makes alignment easier. So, if you provide code that is all timetable oriented, that may be easier to come up with a better correlation and delays.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!