s1 s2 s10 s9: % - PN Sequence - %
s1 s2 s10 s9: % - PN Sequence - %
clear all
% s1 = s9 + s10
% n stage
% period
% initial state
for i=2:T
new_reg(1) = mod(sum(state.*reg),2);
for j=2:n
new_reg(j)=reg(j-1);
end
reg = new_reg;
m_seq(i) = reg(n);
end
s1 = s9 + s10
s1 s2
...
s9 s10
m-sequence
1000000000100000000110000000101000000111100000100010000110011000101010100111111110100000001110
0000010010000011011000010110100011101110010011001011010101110111111001100000101010000111111000
1000001001100001101010001011111001110000101001000111101100100011010110010111101011100011110010
0100010110110011101101010011011111010110000111101000100011100110010010101011011111110110000001
1010000010111000011100100010010110011011101010110011111101010000011111000010000100011000110010
1001010111101111100011000010010100011011110010110001011101001110011101001010011101111010011000
1110101001001111101101000011011100010110010011101011010011110111010001100111001010100101111110
1110000011001000010101100011111010010000111011000100110100110101110101111001111000101000100111
1001101000101011100111110010100001011110001110001001001001101101101011011011110110110001101101
0010110111011101100110011010101010111111111100000000010000000011000000010100000011110000010001
% **Autocorrelation** %
Rxx =1/L*xcorr(X1,L);
% r = xcorr(x) returns the autocorrelation sequence of x.
% r = xcorr(___,maxlag) limits the lag range from -maxlag to maxlag.
lags = -L:1:L;
figure()
subplot(2,1,1);
plot(lags,Rxx);
title('Auto-correlation Function of white noise');
xlabel('Lags')
ylabel('Correlation')
Mean =0.0023
Variance 2=0.9916
Auto-correlation R x [ n ] = [n]
Power Spectral Density
S x ( f )=1
mean = 0;
% mean
sigma2 = 2;
% standard deviation
X2 = sigma2*randn(L,1) + mean;
figure();
subplot(2,1,1)
plot(X2);
title(['White Gaussian noise : \mu_x=',num2str(mean),'
\sigma^2=',num2str(sigma2^2)])
xlabel('Samples')
ylabel('Sample Values')
x = linspace(-15,15,200);
g = (1/(sqrt(2*pi)*sigma2))*exp(-((x-mean).^2)/(2*sigma2^2));
subplot(2,1,2);
plot(x,g);
title('The PDF of White Gaussian Noise');
xlabel('x');
ylabel('PDF f_x(x)');