Got something confused simulating the match filter in base-band transmission system.

2 views (last 30 days)
I'm trying to simulating the match filter on matlab. the pulse shape is SRRC and the signal is 4Pam,here is my problem:after the match filter in the receiver the information is partly missing. I am wondering if someone could help figure out why. Thanks.
Here is the main function
% recfilt.m: undo pulse shaping using correlation
str='This is Steven'; % message to be transmitted
m=Fletters2pam4(str); N=length(m); % 4-level signal of length N
M=10; mup=zeros(1,N*M); mup(1:M:end)=m; % oversample by M
L=10; ps=Fsrrc(L,1,M); % blip pulse of width M
x=filter(ps,1,mup); % convolve pulse shape with data
y=xcorr(x,ps); % correlate pulse with received signal
z=y(N*M:M:end)/(pow(ps)*M); % downsample to symbol rate and normalize
mprime=Fquantalph(z,[-3,-1,1,3])'; % quantize to +/-1 and +/-3 alphabet
Fpam2letters(mprime) % reconstruct message
sum(abs(sign(mprime-m))) % calculate number of errors
Fletters2pam4.m
% letters2pam4.m: encode a string of ASCII text into +/-1, +/-3
function f = letters2pam4(str); % call as Matlab function
N=length(str); % length of string
f=zeros(1,4*N); % store 4-PAM coding here
for k=0:N-1 % change to "base 4"
f(4*k+1:4*k+4)=2*(dec2base(str(k+1),4,4))-99;
end
pam2letters.m
% pam2letters.m: reconstruct string of +/-1 +/-3 into letters
function f = newpam2letters(seq)
S = length(seq);
off = mod(S,4);
if off ~= 0
sprintf('dropping last %i PAM symbols',off)
seq = seq(1:S-off);
end
N = length(seq)/4;
for k = 0:N-1
f(k+1) = base2dec(char((seq(4*k+1:4*k+4)+99)/2),4);
end
f = char(f);
Fpow.m
function y=pow(x)
% y=pow(x) calculates the power in the input sequence x
y=sum(x.^2)/length(x);
Fquantalph.m
function y=quantalph(x,alphabet)
% function y=quantalph(x,alphabet)
% quantize the input signal x to the alphabet
% using nearest neighbor method
% input x - vector to be quantized
% alphabet - vector of discrete values that y can take on
% sorted in ascending order
% output y - quantized vector
[r c] = size(alphabet); if c>r, alphabet=alphabet'; end
[r c] = size(x); if c>r, x=x'; end
alpha=alphabet(:,ones(size(x)))';
dist=(x(:,ones(size(alphabet)))-alpha).^2;
[v,i]=min(dist,[],2);
y=alphabet(i);
Fsrrc.m
function s=Fsrrc(syms, beta, P, t_off);
% s=srrc(syms, beta, P, t_off);
% Generate a Square-Root Raised Cosine Pulse
% 'syms' is 1/2 the length of srrc pulse in symbol durations
% 'beta' is the rolloff factor: beta=0 gives the sinc function
% 'P' is the oversampling factor
% 't_off' is the phase (or timing) offset
if nargin==3, t_off=0; end; % if unspecified, offset is 0
k=-syms*P+1e-8+t_off:syms*P+1e-8+t_off; % sampling indices as a multiple of T/P
if (beta==0), beta=1e-8; end; % numerical problems if beta=0
s=4*beta/sqrt(P)*(cos((1+beta)*pi*k/P)+... % calculation of srrc pulse
sin((1-beta)*pi*k/P)./(4*beta*k/P))./...
(pi*(1-16*(beta*k/P).^2));

Answers (0)

Categories

Find more on Transforms and Spectral Analysis in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!