You are on page 1of 2

clc, clear, close all

Es = 10; % N?ng l??ng m?i bit


n = 5; % B?c c?a b? l?c
N = 1e6; % T?c ?? bit
phi0 = pi/2; % Pha tín hi?u phát
fs = 5e6; % T?n s? l?y m?u
fc = 1e6; % T?n s? sóng mang
ts = 1/fs; % Th?i gian l?y m?u
Nsym = N/3; % T?c ?? ký hi?u
tsym = 1/Nsym; % Th?i gian 1 ký hi?u

d = randint(3,2000,[0 1]); % T?o chu?i các bit ng?u nhiên t??ng ?ng v?i các ký hi?u
h = modem.pskmod('M', 8, 'InputType', 'Bit'); % ?i?u ch? 8PSK
y = modulate(h, d); % T?o chu?i 8 ký hi?u 8PSK t??ng ?ng

t = 0:ts:30e-5;
s1 = zeros(1, length(t));

for l=1:length(t)% Vong lap bat dau thuc hien dieu che
s=0;
for k=1:100
a(k)=(t(l)-0.5*tsym-(k-1)*tsym)/tsym;
s=s+y(k)*sqrt((2*Es)/tsym)*rect(a(k));
end
s1(l)=s*exp(j*phi0);%tin hieu phat tuong duong bang goc
end

s2 = raisedcosflt(s1,1.5e6,ts,0.5);% Bo loc redcosflt


sp = sqrt(2)*real(s1.*exp(j*2*pi*fc*t));% Tin hieu thong dai 8PSk
plot(t,sp,'k')
axis([0 4e-5 -2000 2000])
title('Tin hieu thong dai 8PSK')

%Bieu dien tin hieu phat tuong duong bang goc 8PSK
figure
plot(t,real(s1),'r')
title('Dang tin hieu bang goc 8PSK')
xlabel('Time')
ylabel('Bien do')
grid on
axis([0 6e-5 -1500 1500])

%Bieu dien chom sao


h = scatterplot(y,1,0,'*k');
title('chom sao tin hieu 8-PSK')

%Bieu dien mau mat


eyediagram(real(s2),30);
title('mau mat tin hieu 8PSK')

% Bieu dien pho


figure
[f,Pf] = pho(t,real(s1));
plot(f,Pf,'m')
title('pho tin hieu bang goc 8PSK')
xlabel('f-Hz')
ylabel('Pf')
grid on
axis([-2e6 2e6 0 3e4])

% Truyen qua kenh AWGN


SNRdB = 10;% dB
SNR = 10^(SNRdB/10);
varn = var(s1)/SNR;% computing variance of noise
s1_awgn = addnoise(s1,varn);
figure
plot(t,real(s1_awgn),'r')
grid on

title('Tin hieu 8PSK truyen qua AWGN')


axis([0 6e-5 -1500 1500])
% Bieu dien chom sao
y_awgn = awgn(y,10,'measured');
h = scatterplot(y_awgn,1,0,'xg');
hold on;
scatterplot(y,1,0,'or',h);
title('chom sao tin hieu 8PSK truyen qua AWGN')

% Bieu dien mau mat


eyediagram(real(s1_awgn),40);
title('Mau mat tin hieu 8PSK truyen qua AWGN')

% Bieu dien pho


figure
[f,Pf] = pho(t,real(s1_awgn));
plot(f,Pf,'m');
title('Pho tin hieu 8PSK truyen qua AWGN')
grid on
axis([-2e6 2e6 0 3e4])

You might also like