www.pudn.com > estimate-ar.rar > p501.m


%program p501 
clf  %clear the variable 
N=1000; 
n=0:N-1; 
Fs=500; 
t=n/Fs; 
Lag=100; 
x=sin(2*pi*20*t)+0.6*randn(1,length(t)); 
[c,lags]=xcorr(x,Lag,'unbiased'); 
subplot(221); 
plot(t,x) 
xlabel('t'); 
ylabel('x(t)') 
title('orignal signal x'); 
grid; 
subplot(222); 
plot(lags/Fs,c); 
xlabel('t'); 
ylabel('Rx(t)') 
title('autocorrelation'); 
grid; 
x1=randn(1,length(x)); 
[c,lags]=xcorr(x1,Lag,'unbiased'); 
subplot(223); 
plot(t,x1) 
xlabel('t'); 
ylabel('x1(t)') 
title( 'White Noise'); 
grid; 
subplot(224); 
plot(lags/Fs,c); 
xlabel('t'); 
ylabel('Rx1(t)') 
title('autocorrelation'); 
grid;