我遇到了查找信号互相关的问题。没有filtere版本,但ROTH过滤器版本不起作用。你能告诉我这个问题吗?感谢
tho=2;
A=1;
t=-15:0.1:15;
FFTLength=length(t);
x= rect( t+1,tho,A ); % First rectangle signal
plot(t,x)
hold on
y=rect(t-4,tho,A);
plot(t,y,'r')
for i=1:length(x)
x(i)=x(i)+normrnd(0,0.1);
end
figure
plot(t,x,'r')
for i=1:length(y)
y(i)=y(i)+normrnd(0,0.1);
end
figure
plot(t,y,'r')
Rxx = xcorr(x);
Ryy = xcorr(y);
Rxy = xcorr(x,y);
Sxx = fft(Rxx,FFTLength);
Syy = fft(Ryy,FFTLength);
Sxy = fft(Rxy,FFTLength);
X=fft(x,301);
Y=fft(y,301);
%Filtering
H=1;
X2=X.*H;
Y2=Y.*H;
x_t=ifft(X2);
y_t=ifft(Y2);
[correlation,lags] = xcorr(y_t,x_t);
delay = lags(find(correlation==max(correlation)))
disp('Plain time ')
X2=fft(x).*(1./Sxx);
Y2=fft(Y).*(1./Sxx);
x2=real(ifft(X2));
y2=real(ifft(Y2));
[correlation2,lags2] = xcorr(x2,y2);
delay2 = lags2(find(correlation2==max(correlation2)))
disp('ROTH Filter ');
顺便说一句,是
function [ y ] = rect( t,tho,A )
for i = 1 : length(t)
if -(tho / 2) <= t(i) && t(i) <= (tho / 2)
y(i) = A * 1;
else
y(i) = 0;
end
end
end