Documente Academic
Documente Profesional
Documente Cultură
MATLAB Exercise
Exercise 1
L = 256;
for n=0 : L-1
s(n+1)=sin((0.2).*2*pi*n);
end
w = randn(1,L);
x = s+w;
auto_corr_xn=xcorr(x);
Fourier_tx_sin=abs(fft(s,L));
Fourier_tx_xcorr=abs(fft(auto_corr_xn,L));
PSD_sin=Fourier_tx_sin.^2
PSD_xcorr=Fourier_tx_xcorr.^2
figure (1)
plot(Fourier_tx_sin);
title('PSD of Sequence');
figure (2)
plot(Fourier_tx_xcorr);
title('PSD of Fourier');
Exercise 2
() = () + 0.5 ( 1)
In z domain
() = () + 0.5. () 1
() = ()(1 + 0.5 1 )
()
= (1 + 0.5 1 )
( )
|()|2 = |1 + 0.5 1 |2
2
By observing attenuation of the output spectrum, we know that filter spectra form a band pass filter
with specific range.
Exercise 3
%% generate gaussian white noise signal v(n) with L = 256
L=256;
vn=randn(1,L);
%% generate difference equation x(n)
for n=1 :L
if (n-2)<=0
xn(n)=0+vn(n)
else
xn(n)=0.9*xn(n-1)-0.5*xn(n-2)+vn(n)
end
end
%% computing autocorrelation of x(n)
auto_corr_seq_xn=xcorr(xn,L)
%% auto correlation matrix with the first six value of autocorrelation seq.
auto_corr_Mat_xn=auto_corr_seq_xn(1:6);
toep=toeplitz(auto_corr_Mat_xn)
%% calculate AR
a=inv(toep)*(auto_corr_Mat_xn');
1.0000
0.0000
-0.0000
0.0000
-0.0000
0.0000
__________________________________________________________________________________
Exercise 4
a. Generating White Gaussian Noise
Matlab Script :
%% genarating N=1000 samples of white Gaussian noise
N = 1000; %% Sample length
mu = 0; %% zero mean
noise = randn(1,N)+mu; %% white gaussian noise
Matlab output
msq_err =
0.0111
The estimate value is close enough with the true autocorrelation. Mean square error of
difference true value and estimate value is 0.0111.
Compared to part (b), it gives better estimation, with mean square error estimation between
estimate & true value 0.001.
d. Matlab output for 10000 sample
msq_err =
0.0098
The estimate value of N=10000 is closer to the true autocorrelation value compared to
estimate value of N=1000. Mean square error of difference true value and estimate value of
10000 sample 0.0098.