In: Electrical Engineering
|
(a) MATLAB code is given below:
fsin = 1000;%% sine wave frequency
fs = 10000;%% sampling frequency
fbin = fsin/100;%% bin frequency of FFT
npoints = fs/fbin*15;% Total length of sequence
nfft = fs/fbin;% No of points of FFT
A = 1;% amplitude of sinewave
vsin = A*sin(2*pi*fsin/fs*(0:1:npoints-1));% sine wave
defined
noise = wgn(1,length(vsin),-40);% noise witj -40dB power
defined
nfft_total = 10*nfft;% total length of sequence used for
calculating PSD
vsin_final = vsin(end-nfft_total+1:end);
noise_final = noise(end-nfft_total+1:end);
noise_plus_sine = noise+vsin;% noise + signal
noise_plus_sine_final = noise_plus_sine(end-nfft_total+1:end);
%%% Generating 10 different FFT's by dividing sequence into ten
segments
%%% and then taking FFT of each segment
fft_vsin(nfft_total/nfft,nfft) = 0;
fft_noise(nfft_total/nfft,nfft) = 0;
fft_noise_plus_sine(nfft_total/nfft,nfft) = 0;
for i = 1:nfft_total/nfft
fft_vsin(i,:) = fft(vsin_final((i-1)*nfft+1:i*nfft));
fft_noise(i,:) = fft(noise_final((i-1)*nfft+1:i*nfft));
fft_noise_plus_sine(i,:) =
fft(noise_plus_sine_final((i-1)*nfft+1:i*nfft));
end
freq = fs/nfft*(0:1:nfft-1);
%%%%
psd_vsin_avg(1,nfft) = 0;
psd_noise_avg(1,nfft) = 0;
psd_noise_plus_sine_avg(1,nfft) = 0;
for i = 1:nfft_total/nfft
psd_vsin_avg = psd_vsin_avg + abs(fft_vsin(i,:)).^(2);
psd_noise_avg = psd_noise_avg + abs(fft_noise(i,:)).^(2);
psd_noise_plus_sine_avg = psd_noise_plus_sine_avg +
abs(fft_noise_plus_sine(i,:)).^(2);
end
psd_vsin_avg = psd_vsin_avg(1:nfft/2)/(2000*2000);% scaling factor
to normalize PSD
psd_noise_avg = psd_noise_avg(1:nfft/2)/(2000*2000);% scaling
factor to normalize PSD
psd_noise_plus_sine_avg =
psd_noise_plus_sine_avg(1:nfft/2)/(2000*2000);% scaling factor to
normalize PSD
frequency = freq(1:nfft/2);
PSD of signal, PSD of noise and PSD of signal + noise is plotted below:
(b) From plot, we can see that signal is single sinusoid but noise spread over whole frequency range. So ideal filter to filter out noise will be a bandpass filter centered at 1kHz and infinite Q such that its bandwidth = 0.