0% found this document useful (0 votes)
22 views3 pages

s1 s2 s10 s9: % - PN Sequence - %

This document discusses different types of random signals including: 1. A maximal length sequence (m-sequence) generated from a 10-stage binary linear feedback shift register with an initial state and period of 1023. 2. White noise which has a delta function autocorrelation and flat power spectral density. 3. White Gaussian noise which has a normal probability distribution and is used to generate realizations of random signals. 4. Rayleigh distribution which models the amplitude of signals with random phase and can be generated from the sum of two independent normal random variables.

Uploaded by

黃郁淨
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views3 pages

s1 s2 s10 s9: % - PN Sequence - %

This document discusses different types of random signals including: 1. A maximal length sequence (m-sequence) generated from a 10-stage binary linear feedback shift register with an initial state and period of 1023. 2. White noise which has a delta function autocorrelation and flat power spectral density. 3. White Gaussian noise which has a normal probability distribution and is used to generate realizations of random signals. 4. Rayleigh distribution which models the amplitude of signals with random phase and can be generated from the sum of two independent normal random variables.

Uploaded by

黃郁淨
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

clc

clear all

% ---------------------- PN sequence ---------------------- %


state = [0 0 0 0 0 0 0 0 1 1];
n = length(state);
T = 2^n - 1;
reg = [zeros(1,n-1) 1];
m_seq(1) = reg(n);

% 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

10 stage binary linear


feedback shift register

initial value = 0000000001


period = 2101=1023

1000000000100000000110000000101000000111100000100010000110011000101010100111111110100000001110
0000010010000011011000010110100011101110010011001011010101110111111001100000101010000111111000
1000001001100001101010001011111001110000101001000111101100100011010110010111101011100011110010
0100010110110011101101010011011111010110000111101000100011100110010010101011011111110110000001
1010000010111000011100100010010110011011101010110011111101010000011111000010000100011000110010
1001010111101111100011000010010100011011110010110001011101001110011101001010011101111010011000
1110101001001111101101000011011100010110010011101011010011110111010001100111001010100101111110
1110000011001000010101100011111010010000111011000100110100110101110101111001111000101000100111
1001101000101011100111110010100001011110001110001001001001101101101011011011110110110001101101
0010110111011101100110011010101010111111111100000000010000000011000000010100000011110000010001

% ---------------------- White Noise ---------------------- %


L = 100000;
X1 = randn(L,1);
figure()
plot(X1);
title('White noise')
xlabel('Samples')
ylabel('Sample Values')

% Sample length for the random signal

% **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')

% **Power Spectral Density** %


N = 1024;
% Sample length for each realization set as power of 2 for FFT
mu = mean(X1);
sigma1 = sqrt(var(X1));
MU = mu*ones(1,N);
% Vector of mean for all realizations
Cxx=(sigma1^2)*diag(ones(N,1));
% Covariance Matrix for the Random Process
R = chol(Cxx);
% Cholesky of Covariance Matrix
z = repmat(MU,L,1) + randn(L,N)*R;
Z = 1/sqrt(N)*fft(z,[],2);
% Scaling by sqrt(N);
Pzavg = mean(Z.*conj(Z));
% Computing the mean power from fft
normFreq = [-N/2:N/2-1]/N;
Pzavg = fftshift(Pzavg);
% Shift zero-frequency component to center of spectrum
subplot(2,1,2);
plot(normFreq,Pzavg,'r');
axis([-0.5 0.5 0 2]); grid on;
ylabel('Power Spectral Density');
xlabel('Normalized Frequency');
title('Power spectral density of white noise');

Mean =0.0023
Variance 2=0.9916
Auto-correlation R x [ n ] = [n]
Power Spectral Density
S x ( f )=1

% ------------------ White Gaussian Noise ------------------ %

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)');

% ------------------ Rayleigh distributed ------------------ %


x1 = randn(L,1);
x2 = randn(L,1);
x3 = sqrt(x1.^2+x2.^2);
a = var(x3)
% sigma square
fx = (x3./a).*exp(-x3.^2/(2*a));
figure()
plot(x3,fx)
title(['The PDF of Rayleigh distributed with \sigma^2=',num2str(a)]);
xlabel('x');
ylabel('PDF f_x(x)');

You might also like