Home  |  DSP  |  Kalman Filter  |  Robotics  |  OpAmps  |  I2C Bus  |  Products 

Try a High End PIC17C756/PIC18C658 Single-Board-Computer Module with a proto area that can be replaced.

We offer free support with Sample programs, Tutorials, and Design examples.


CORRELATION


Autocorrelation Example in MatLab

%************************************************************
% Tim Hawkins
% 5/20/98
% AutoCorrelation of White Noise
% Loops are used in this program for easier portability to 
% C or assembly code.
%
%************************************************************
% N = Length of Time Domain Signal

N = 512;

%************************************************************
% Create an index matrix for graphing:
%************************************************************

for n = 1: 1: N;

	index(n) = n;

end

%************************************************************
% Create an expanded index matrix from -N to N for graphing:
%************************************************************

index_expanded = 1:(2*N - 1);

for n = 1: 1: (N - 1);

	index_expanded(n) = -(index(N - n));

end

index_expanded(N) = 0;

for n = (N + 1): 1: (2*N - 1);

	index_expanded(n) = index(n - N);

end

%************************************************************
%  Generate the flat +- 0.1 white noise:
%************************************************************

w_2 = 1:N;

w_2 = 0.1*rand(1,N);

w_2 = w_2 - mean(w_2);

%************************************************************
% Compute 0.1 white noise Autocorrelation:
%************************************************************

r_xx_w_2 = 1:N;

for m = 1: 1: N;

F = 0;

	for k = 1: 1: (N+1-m);

		F = F + w_2(k)*w_2(k-1+m);

	end

	r_xx_w_2(m) = F/(N+1-m);

end

%************************************************************
% Create an expanded 0.1 white noise Autocorrelation Function
% from -N to N for graphing purposes:
%************************************************************

r_xx_w__expanded = 1:(2*N - 1);

for m = 1: 1: N;

	r_xx_w_2_expanded(m) = r_xx_w_2(N - m + 1);

end

for m = N: 1: (2*N - 1);

	r_xx_w_2_expanded(m) = r_xx_w_2(m + 1 - N);

end

%************************************************************
% Plot the Results
%************************************************************

figure
plot(index_expanded,r_xx_w_2_expanded)
title(['Auto Correlation Function of 0.1 w.n Input'])

%************************************************************


Try a High End PIC17C756/PIC18C658 Single-Board-Computer Module with a proto area that can be replaced.

We offer free support with Sample programs, Tutorials, and Design examples.



 Home  |  DSP  |  Kalman Filter  |  Robotics  |  OpAmps  |  I2C Bus  |  Products