|
Hi,
I need to implement communication system in Matlab. One of many problems that I have is to excecute the code below using fir2 filter, and then I need to use created filter to filter NRZ code.
Can you please help me by giving me some advices.
clear all
close all
clc
Ts = 5e-2;
Tb = 1e-1;
Nb = 1e5;
bs = round(rand(1,Nb));
%bs = [1 0 1 0 1 1 0 0 1];
% Nb = size(bs,2);
x = 0;
M = Tb/Ts;
for k = 1:Nb
%x = [x bs(k)*ones(1,Tb/Ts)] ;
if(bs(k) == 0)
x(M*(k-1)+1:k*M) = -1*ones(1,Tb/Ts);
else
x(M*(k-1)+1:k*M) = 1*ones(1,Tb/Ts);
end
end
%save testfiles 'x' 'bs'
%x = x(2:end);
%figure(1)
%subplot(3,1,1)
%stem(0:size(bs,2)-1,bs)
%subplot(3,1,2)
t = 0:1:(size(x,2)-1);
t = t*Ts;
%plot(t,x,'m','LineWidth',4);
%hold on
EbN0 =[1 5 10 15 20 25];
% EbN0 = SNR *Tb/Ts;
SNR = EbN0*Ts/Tb;
for n = 1:size(SNR,2)
y = awgn(x,SNR(n),'measured');
%plot(t,x,'k')
tod = round(M/2);
pod = 0;
for k=1:Nb
t_symbol = y(M*(k-1)+1:M*k);
t_symbol = t_symbol(tod);
if(t_symbol > pod)
dbs(k) = 1;
else
dbs(k) = 0;
end
end
|