0% found this document useful (0 votes)
21 views4 pages

Matched Filter Output

The document simulates digital communication using pulse amplitude modulation (PAM). It generates random input symbols, performs PAM modulation, oversamples the signal, applies a square root raised cosine (SRRC) pulse shaping filter, adds additive white Gaussian noise (AWGN) at a given signal-to-noise ratio (SNR), and performs matched filtering on the received signal. Functions are defined to implement the SRRC pulse shaping filter and add AWGN noise to a signal according to a specified SNR. Plots of the signals are generated after each step.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views4 pages

Matched Filter Output

The document simulates digital communication using pulse amplitude modulation (PAM). It generates random input symbols, performs PAM modulation, oversamples the signal, applies a square root raised cosine (SRRC) pulse shaping filter, adds additive white Gaussian noise (AWGN) at a given signal-to-noise ratio (SNR), and performs matched filtering on the received signal. Functions are defined to implement the SRRC pulse shaping filter and add AWGN noise to a signal according to a specified SNR. Plots of the signals are generated after each step.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Program:

clc; clear all;

N = 10^2; %Number of symbols to transmit


MOD_TYPE = 'AM'; %modulation type
M = 4; %modulation level for the chosen modulation MOD_TYPE
d = ceil(M.*rand(1,N)); %random numbers from 1 to M for input to PAM
u = modulate(d, 3e3, 8000, MOD_TYPE);%MPAM modulation
figure; stem(real(u)); %plot modulated symbols
%Upsampling
L=4; %Oversampling factor (L samples per symbol period)
v=[u;zeros(L-1,length(u))];%insert L-1 zero between each symbols
%Convert to a single stream
v=v(:).';%now the output is at sampling rate
figure; stem(real(v)); title('Oversampled symbols v(n)');

%SRRC pulse shaping


%----Pulse shaping-----
beta = 0.3;% roll-off factor for Tx SRRC filter
Nsym=8;%SRRC filter span in symbol durations
L=4; %Oversampling factor (L samples per symbol period)
[p,t,filtDelay] = srrcFunction(beta,L,Nsym);%design filter
s=conv(v,p,'full');%Convolve modulated syms with p[n] filter
figure; plot(real(s),'r'); title('Pulse shaped symbols s(n)');
%Adding AWGN noise for given SNR value
EbN0dB = 10; %EbN0 in dB for AWGN channel
snr = 10*log10(log2(M))+EbN0dB; %Converting given Eb/N0 dB to SNR
%log2(M) gives the number of bits in each modulated symbol
r = add_awgn_noise(s,snr,L); %AWGN , add noise for given SNR, r=s+w
%L is the oversampling factor used in simulation
figure; plot(real(r),'r');title('Received signal r(n)');
%Matched filtering with SRRC pulse shape
vCap=conv(r,p,'full');%convolve received signal with Rx SRRC filter
figure; plot(real(vCap),'r');
title('After matched filtering $\hat{v}$(n)','Interpreter','Latex');

SSRC Function:
function [p,t,filtDelay]=srrcFunction(beta,L,Nsym)
%Function for generating square-root raised-cosine (SRRC) pulse
% beta - roll-off factor of SRRC pulse,
% L - oversampling factor (number of samples per symbol)
% Nsym - filter span in symbol durations
%Returns the output pulse p(t) that spans the discrete-time base
%-Nsym:1/L:Nsym. Also returns the filter delay when the function
%is viewed as an FIR filter
Tsym=1; t=-(Nsym/2):1/L:(Nsym/2);%unit symbol duration time-base
num = sin(pi*t*(1-beta)/Tsym)+...
((4*beta*t/Tsym).*cos(pi*t*(1+beta)/Tsym));
den = pi*t.*(1-(4*beta*t/Tsym).^2)/Tsym;

200051601010 – Jawadhur Raffiwoo


p = 1/sqrt(Tsym)*num./den; %srrc pulse definition
%handle catch corner cases (singularities)
p(ceil(length(p)/2))=1/sqrt(Tsym)*((1-beta)+4*beta/pi);
temp=(beta/sqrt(2*Tsym))*( (1+2/pi)*sin(pi/(4*beta)) ...
+ (1-2/pi)*cos(pi/(4*beta)));
p(t==Tsym/(4*beta))=temp; p(t==-Tsym/(4*beta))=temp;
%FIR filter delay = (N-1)/2, N=length of the filter
filtDelay = (length(p)-1)/2; %FIR filter delay
end

Add AWG noise:


function [r,n,N0] = add_awgn_noise(s,SNRdB,L)
%Function to add AWGN to the given signal
%[r,n,N0]= add_awgn_noise(s,SNRdB) adds AWGN noise vector to signal
%'s' to generate a %resulting signal vector 'r' of specified SNR
%in dB. It also returns the noise vector 'n' that is added to the
%signal 's' and the spectral density N0 of noise added
%[r,n,N0]= add_awgn_noise(s,SNRdB,L) adds AWGN noise vector to
%signal 's' to generate a resulting signal vector 'r' of specified
%SNR in dB. The parameter 'L' specifies the oversampling ratio used
%in the system (for waveform simulation). It also returns the noise
%vector 'n' that is added to the signal 's' and the spectral
%density N0 of noise added
s_temp=s;
if iscolumn(s), s=s.'; end; %to return the result in same dim as 's'
gamma = 10^(SNRdB/10); %SNR to linear scale
if nargin==2, L=1; end %if third argument is not given, set it to 1
if isvector(s),
P=L*sum(abs(s).^2)/length(s);%Actual power in the vector
else %for multi-dimensional signals like MFSK
P=L*sum(sum(abs(s).^2))/length(s); %if s is a matrix [MxN]
end
N0=P/gamma; %Find the noise spectral density
if(isreal(s)),
n = sqrt(N0/2)*randn(size(s));%computed noise
else
n = sqrt(N0/2)*(randn(size(s))+1i*randn(size(s)));%computed noise
end
r = s + n; %received signal
if iscolumn(s_temp), r=r.'; end;

200051601010 – Jawadhur Raffiwoo


Output:
Input Discrete signal:

Oversampled Signal:

Pulse Shape Signal:

200051601010 – Jawadhur Raffiwoo


Received Signal:

After Matched Filter:

200051601010 – Jawadhur Raffiwoo

You might also like