clear; % sampling frequency fs = 1e9; % time duration for pulse of start and end td = 10e-9; % number of steps in linspace N = 513; % width of rect pulse w= 1e-9; % time t = linspace(-td,td,N); dt = t(2)-t(1); T = t(end)-t(1) + (t(2)-t(1)); f = 1/T * (-(N-1)/2 : (N-1)/2); %square pulse subplot(3,2,1) y = rectpuls(t,w); plot(t,y) xlabel('Time') ylabel('Amplitude') title('rectangular pulse') grid on; %fourier transform of square pulse: ATsinc(fT) %where f is a frequency variable. A is the amplitude of the pulse, %assumed to be 1 subplot(3,2,2) Y = w*fft(y); sz = size (y) Yplot = fftshift(Y); plot(f,abs(Yplot)) xlabel('frequency') ylabel('Amplitude') title('fft=sinc func') grid on;
% noise added with signal x = awgn(y,10,'measured'); subplot(3,2,3) plot(t,[y x]) legend('Original Signal','Signal with AWGN') title('signal and noise') grid on % convolution at multiplier s1=fft(x); s2=fft(y); y2=conv(s1,s2) subplot(3,2,4) plot(y2) title('convolution of FFT') grid on % matched filter output y3=ifft(y2); subplot(3,2,5) plot(y3) title('matched filter output') grid on
Best Answer