Академический Документы
Профессиональный Документы
Культура Документы
H v tn : H c Trung
Lp : T 06 K54
Mssv: 20092855
Bi 1
1.1 V hm phn b xc sut Gauss ca bin ngu nhin cho bi cng thc
P(x) =
Gii:
Code:
x=-4:0.05:4; %bien x lay gia tri tu (-4,4), moi gia tri cach nhau 0.05
p=1/sqrt(2*pi)*exp(-x.^2/2);
plot(x,p); %ham ve do thi lien tuc
title('Ham phan bo xac suat Gauss cua bien ngau nhien');
xlabel('x');
ylabel('P(x)');
th
Bi 2
V hm t tng quan ca tn hiu
Code
x=-4:0.05:4;
p=1/sqrt(2*pi)*exp(-x.^2/2);
z=conv(p,p); %ham tu tuong quan
plot(z);%ve ham tu tuong quan
title('Ham tu tuong quan cua phan bo Gauss');
xlabel('x');
ylabel('z');
th
Bi 3
3.1 M ng dy NRZ
Code
N = 10^6
u = rand(1,N)>0.5; % to mt vecto N bit ngu nhin
s = 2*u-1; % iu ch BPSK, u
n = 1/sqrt(2)*[randn(1,N) + j*randn(1,N)]; % to mt nhiu phc Gauss
SNR = 0:2:6; % t l tn hiu trn tp m [dB]
for i = 1:length(SNR)
y = s + 10^(-SNR(i)/20)*n; % cng nhiu trng
uHat = real(y)>0; % k hiu thu c
c(i) = size(find([u- uHat]),2);
end
BER = c/N;
theoryBer = 0.5*erfc(sqrt(10.^(SNR/10))); % xc sut li bit l thuyt
save bpsk BER; % lu file phc v bi 3.2
semilogy(SNR,BER,'b.-');
xlabel('SNR[dB]');
ylabel('BER');
title('BER/SNR');
th
th
Bi s 4
4.1 Biu chm sao ca tn hiu iu ch QPSK m ha theo m Gray :
Code
x=round(rand(1,10000));% to mt vecto bit ngu nhin
for i=1:2:length(x) % vng lp t 1 ti di x, bc nhy 2
switch x(i)
% s dng switch case la chn m ha
case 0
if x(i+1)==0
s((i+1)/2)=exp(j*pi/4);
else
s((i+1)/2)=exp(j*3*pi/4);
end
case 1
if x(i+1)==0
s((i+1)/2)=exp(j*7*pi/4);
else
s((i+1)/2)=exp(j*5*pi/4);
end
end
end
save Bai4p1 s x;
plot(s,'*');
hold on;
t=0:0.01:2*pi; % khai bo bin t
plot(exp(j*t),'k--'); % v ng trn n v, mu en, nt t
xlabel('phi(t)');
ylabel('s_m');
title('Bieu do khong gian trang thai tin hieu dieu che QPSK voi ma Gray');
th
Eb=Es/2;
SNR_db=6; % gi thit
N_0=Eb/10.^(SNR_db/10);
N=sqrt(N_0/2)*(randn(size(s))+j*randn(size(s)));% nhiu trng phc cng chiu di
vi tn hiu QPSK
R=s+N; % tn hiu thu c
plot(R,'.');
hold on;
plot(s,'r*');% v biu chm sao ca t nhiu QPSK
hold on;
t=0:0.01:2*pi;
plot(exp(j*t),'r--');% v ng trn n v, nt t, mu
legend('S_m','S');
%S_m chm sao ca tn hiu thu c
% S chm sao ca tn hiu QPSK
title('Bieu do chom sao tin hieu thu duoc');
xlabel('I');
ylabel('Q');
hold off;
th
Bi s 5
M phng h thng truyn dn s bng tn c s QPSK :
Code
% Hm gii iu ch QPSK v m li bit xut hin trong qu trnh pht, lu vi tn
%'cha'
function y =cha(SNR_db,S,x)
Es=var(S);
Eb=Es/2;
N_0=Eb/10^(SNR_db/10); % t SNR_db=10log(Eb/N_0)
N0=sqrt(N_0/2)*(randn(size(S))+j*randn(size(S)));% to nhiu trng phc
NS=S+N0;% tn hiu thu c
theta_m=[pi/4,3*pi/4,5*pi/4,7*pi/4];
S_m=exp(j*theta_m);% vng lp so snh lch ca k hiu thu c
% vi cc gi tr k hiu chun.
for i=1:length(S)
d=abs(S_m-NS(i));
md=min(abs(S_m-NS(i)));
if md==d(1);
R(2*i-1)=0;
R(2*i)=0;
elseif md==d(2);
R(2*i-1)=0;
R(2*i)=1;
elseif md==d(3);
R(2*i-1)=1;
R(2*i)=1;
elseif md==d(4);
R(2*i-1)=1;
R(2*i)=0;
end
end
c=0; % mc nh bin m li bt bng 0
for i=1:length(x)
if R(i)~=x(i);
c=c+1;
end
end
y=c; % tr v y
end
%##########################
%Main function:
%##########################
clear all
load Bai4p1 s x
% load file exp5p1_Res c lu bi 4.1
SNR_db=0:2:8;
% vng lp xc nh s li bt
% ng vi gi tr SNR[dB] khc nhau
for i=1:length(SNR_db)
c(i)=cha(SNR_db(i),s,x);
end
BEP=c/length(x);
% xc sut li bt
semilogy(SNR_db,BEP,'.--');
% v th nt '.--'
title('Do thi ti le loi bit voi ti le tin hieu tren nhieu');
xlabel('SNR[dB]');
ylabel('Pb');
save Bai5 c BEP;
Bi s 6
Tnh t l li bit l thuyt
Code
clear all;
SNR_db=0:8;% SNR[dB] l thuyt
SNR_db_mp=0:2:8;% SNR[dB] m phng
for i=1:length(SNR_db)
SNR(i)=10^(SNR_db(i)/10);
gamma_b(i)=SNR(i);
p_b(i)=erfc(sqrt(2*gamma_b(i))/sqrt(2))/2;% hm li b
end
semilogy(SNR_db,p_b,'--')% v th l thuyt
hold on; % v thm hnh
load Bai5 c BEP;% load hm m phng bi 5
semilogy(SNR_db_mp,BEP,'o--') % v th m phng
title('So sanh ket qua ly thuyet v mo phong');
xlabel('SNR[dB]');
ylabel('Pb');
legend('Ly thuyet','Mo phong');
th