In this tutorial, we will take a look at the mathematical function called auto-correlation for various common signals. The basic signals are generated and their respective auto-correlation output is plotted.
Screen Display Settings
scrsz = get(0,'ScreenSize');
P1 = [50 500 scrsz(3)/3 scrsz(4)/3];
P2 = [50 80 scrsz(3)/3 scrsz(4)/3];
P3 = [500 500 scrsz(3)/1.5 scrsz(4)/3];
P4 = [500 80 scrsz(3)/1.5 scrsz(4)/1.5];
Generate Basic Signals
figure('position', P4);
figure(1);
Sine Wave
t = 0:(1/1000):1;
x1 = sin(2*pi*1*t) ;
subplot(4,2,1);
plot(x1);
grid on
title('Sine Wave');
xlabel('Samples');
ylabel('Amplitude');
y1 = xcorr(x1,x1);
subplot(4,2,2);
plot(y1);
grid on
title('Sine Wave Autocorr');
xlabel('Samples');
ylabel('Amplitude');
Ramp
x2 = t;
subplot(4,2,3);
plot(t);
grid on
title('Ramp');
xlabel('Samples');
ylabel('Amplitude');
y2 = xcorr(x2,x2);
subplot(4,2,4);
plot(y2);
grid on
title('Ramp Autocorr');
xlabel('Samples');
ylabel('Amplitude');
Rectangular
x3 = ones(1,1500);
subplot(4,2,5);
plot(x3);
grid on
title('Rectangular');
xlabel('Samples');
ylabel('Amplitude');
y3 = xcorr(x3,x3);
subplot(4,2,6);
plot(y3);
grid on
title('Rect Autocorr');
xlabel('Samples');
ylabel('Amplitude');
1 minus x^2
x4 = 1- t.*t;
subplot(4,2,7);
plot(x4);
grid on
title('XSquare');
xlabel('Samples');
ylabel('Amplitude');
y4 = xcorr(x4,x4);
subplot(4,2,8);
plot(y4);
grid on
title('XSquare Autocorr');
xlabel('Samples');
ylabel('Amplitude');
End of Program
No comments:
Post a Comment