%corrx_example2.m: example of autocorrelation estimation.
% x(t) = cos(t + theta), where theta is uniformly distributed.
% David Pan for EE 385

sample_period = 0.001;
t = 0: sample_period: 20; 
theta = random('Uniform', 0, 2*pi); 
x = cos(t + theta);
[t1, R] = corb(x, x, 1/sample_period) ; % autocorrelation
subplot(2, 1, 1); 
plot(t,x);
xlabel('TIME'); ylabel('X');
subplot(2, 1, 2); 
plot(t1,R);
xlabel('LAG'); ylabel('RX');