www.pudn.com > estimate-ar.rar > p502.m
%program p502
clf %clear the variable
N=1000;
n=0:N-1;
Fs=500;
t=n/Fs;
Lag=200;
x=sin(2*pi*10*t);
y=0.5*sin(2*pi*10*t+90*pi/180);
[c,lags]=xcorr(x,y,Lag,'biased');
subplot(311);
plot(t,x,'r')
xlabel('t');
ylabel('x(t)');
title('orignal signal');
subplot(312)
plot(t,y,'b')
xlabel('t');
ylabel('y(t)');
title('orignal signal');
grid;
subplot(313);
plot(lags/Fs,c,'r');
xlabel('t');
ylabel('Rxy(t)')
title('correlation');
grid;