互相关 [英] cross correlation

查看:105
本文介绍了互相关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试寻找时移信号响应与作为参考的另一信号响应之间的互相关性,但发现很难用xcorr函数反映我的时移. Matlab代码粘贴在下面,如果有人可以建议如何实现xcorr功能,以便我可以确定两个信号响应之间的时移,我将不胜感激.谢谢

clear all;
clc;
FS = 100e6;



figure(1)
AMP8 = importdata('av250nu.txt');
time8  = [1:length(AMP8)] / FS;
c=find(time8==0.14e-4);
plot(time8(1:c)',AMP8(1:c));
ylabel('Amplitude(V)')
xlabel('Time of flight(s)')

figure(2)
AMP = importdata('3kknu.txt');
time  = [1:length(AMP)] / FS;
c=find(time==0.14e-4);
plot(time(1:c)',AMP(1:c));
title('reference')
ylabel('Amplitude(V)')
xlabel('Time of flight(s)')

figure(3)
AMP1 = zeros(2000,1);
time1 = zeros(2000,1);
time11 = zeros(2000,1);
AMP1(1:320)= AMP(1:320);
time1(1:320) = time(1:320);
plot(time1,AMP1);
ylabel('Amplitude(V)')
xlabel('Time of flight(s)')

figure(4)
AMP2 = zeros(2000,1);
time2 = zeros(2000,1);
time21 = zeros(2000,1);
AMP2(321:640) = AMP(321:640);
time2(321:640) = time(321:640);
time21(321:640) = time2(321:640);
plot(time21,AMP2);
ylabel('Amplitude(V)')
xlabel('Time of flight(s)')

figure(5)
AMP3 = zeros(2000,1);
time3 = zeros(2000,1);
time31 = zeros(2000,1);
AMP3(641:960) = AMP(641:960);
time3(641:960) = time(641:960);
time31(641:960) = time3(641:960);
plot(time31,AMP3);
ylabel('Amplitude(V)')
xlabel('Time of flight(s)')

figure(6)
AMP4 = zeros(2000,1);
time4 = zeros(2000,1);
time41 = zeros(2000,1);
AMP4(961:1280) = AMP(961:1280);
time4(961:1280) = time(961:1280);
time41(961:2000) = time4(961:2000);
plot(time41,AMP4);
ylabel('Amplitude(V)')
xlabel('Time of flight(s)')

figure(75)
time5=zeros(2000,1);
p = zeros(2000,1);
time5(1:320)= time1(1:320); 
time5(321:640)=time21(321:640);
time5(641:960)=time31(641:960);
time5(961:2000)=time41(961:2000);

plot(time5,AMP);

 p(1:2000) = time5;
 p(1:16384) = AMP;
 plot(p);
 grid on;



 figure(95)
 [Z,lags] = XCORR(p(1:16384,1),AMP8,'biased');
 plot(lags,Z);

解决方案

尝试找到相关的最大值,这是所需的位移.

[zmax, i] = max(Z);
t = lags[i];

i have been trying to find the cross correlation between a time shifted signal response and another signal response taken as a reference but finding it difficult to make my time shift reflect with the xcorr function. the matlab code is pasted below, i will appreciate if anybody can make a suggestion on how to implement the xcorr function such that i can determine the time shift at which the two signal response correlate. thank you

clear all;
clc;
FS = 100e6;



figure(1)
AMP8 = importdata('av250nu.txt');
time8  = [1:length(AMP8)] / FS;
c=find(time8==0.14e-4);
plot(time8(1:c)',AMP8(1:c));
ylabel('Amplitude(V)')
xlabel('Time of flight(s)')

figure(2)
AMP = importdata('3kknu.txt');
time  = [1:length(AMP)] / FS;
c=find(time==0.14e-4);
plot(time(1:c)',AMP(1:c));
title('reference')
ylabel('Amplitude(V)')
xlabel('Time of flight(s)')

figure(3)
AMP1 = zeros(2000,1);
time1 = zeros(2000,1);
time11 = zeros(2000,1);
AMP1(1:320)= AMP(1:320);
time1(1:320) = time(1:320);
plot(time1,AMP1);
ylabel('Amplitude(V)')
xlabel('Time of flight(s)')

figure(4)
AMP2 = zeros(2000,1);
time2 = zeros(2000,1);
time21 = zeros(2000,1);
AMP2(321:640) = AMP(321:640);
time2(321:640) = time(321:640);
time21(321:640) = time2(321:640);
plot(time21,AMP2);
ylabel('Amplitude(V)')
xlabel('Time of flight(s)')

figure(5)
AMP3 = zeros(2000,1);
time3 = zeros(2000,1);
time31 = zeros(2000,1);
AMP3(641:960) = AMP(641:960);
time3(641:960) = time(641:960);
time31(641:960) = time3(641:960);
plot(time31,AMP3);
ylabel('Amplitude(V)')
xlabel('Time of flight(s)')

figure(6)
AMP4 = zeros(2000,1);
time4 = zeros(2000,1);
time41 = zeros(2000,1);
AMP4(961:1280) = AMP(961:1280);
time4(961:1280) = time(961:1280);
time41(961:2000) = time4(961:2000);
plot(time41,AMP4);
ylabel('Amplitude(V)')
xlabel('Time of flight(s)')

figure(75)
time5=zeros(2000,1);
p = zeros(2000,1);
time5(1:320)= time1(1:320); 
time5(321:640)=time21(321:640);
time5(641:960)=time31(641:960);
time5(961:2000)=time41(961:2000);

plot(time5,AMP);

 p(1:2000) = time5;
 p(1:16384) = AMP;
 plot(p);
 grid on;



 figure(95)
 [Z,lags] = XCORR(p(1:16384,1),AMP8,'biased');
 plot(lags,Z);

解决方案

Try to find maximum value of correlation, it is the desired shift.

[zmax, i] = max(Z);
t = lags[i];

这篇关于互相关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆