Está en la página 1de 15

BO CO TH NGHIM MN THNG TIN S

H v Tn : Vn Tn
SHSV : 20092332
Lp
: TVT 05 - K54
M lp th nghim :38753
Nm hc: 2011-2012
BI S 1:
QU TRNH NGU NHIN CA TN HIU
1.1
v hm phn b xc sut Gauss
chng trnh :
x=-4:0.05:4;
y=1/sqrt(2*pi)*exp(-x.^2/2);
plot(x,y);
title(ham phan bo xac suat gauss);
xlabel(x);
ylabel(px);
Kt qu:

ham phan bo x ac s uat gauss


0 .4

0 .3 5

0 .3

px

0 .2 5

0 .2

0 .1 5

0 .1

0 .0 5

0
-4

-3

-2

-1

0
x

1.2 s dng hm randn to mt qu trnh ngu nhin vi tr trung bnh v lch chun
Chng trnh :
n=100000;
x=-4:0.05:4;
px=1/sqrt(2*pi)*exp(-x.^2/2);
check=trapz(x,px);
plot(x,px,r);
hold on;
y=randn(1,n);
m=mean(y);
vairiance=std(y)^2;
x2=-4:0.1:4;
c=hist(y,x2);
stem(x2,c/n/(x2(2)-x2(1)));
title(ham mat do phan bo xac suat);
xlabel(x);
ylabel(px);
hold off;

Kt qu:
ham mat do phan bo xac suat
0.45

0.4

0.35

0.3

px

0.25

0.2

0.15

0.1

0.05

0
-4

-3

-2

-1

0
x

Vi n=1000000
Chng trnh
n=1000000;
x=-4:0.05:4;
px=1/sqrt(2*pi)*exp(-x.^2/2);
check=trapz(x,px);
plot(x,px,r);
hold on;
y=randn(1,n);
m=mean(y);
vairiance=std(y)^2;
x2=-4:0.1:4;
c=hist(y,x2);
stem(x2,c/n/(x2(2)-x2(1)));
title(ham mat do phan bo xac suat n=1000000);
xlabel(x);
ylabel(P);
hold off;
Kt qu

BI S 2:
MT PH NNG LNG V HM T TNG QUAN CA TN HIU
Chng trnh:
Hm t tng quan
function [Rxx] = autom(x)
% [Rxx] =autom(x)
% Hm t tng quan ca tn hiu ri rc x
% Number of samples in x.
N=length(x);
Rxx=Zeros(1,N);
for m=1:N+1
For n=1:N-m+1
Rxx(m) =Rxx(m)+x(n)*x(n+m+1);
End;
End;

V hm t tng quan v hm mt ph nng lng


N=100000;
x=randn(1,N);
subplot(3,1,1);
plot(n,x);
title(Tn hiu ngu nhin );
xlabel(N);
ylabel(amplitude);
grid;
Rxx=autom(x);
subplot(3,1,2);
plot (Rxx);
grid;
title( Ham tu tuong quan tin hieu ngau nhien);
xlabel (lags);
ylabel (Autocorrelation);
P=abs (fft (Rxx));
fx = (0:N/2-1) / N;
subplot (3,1,3);
plot(fx,20*log (p (1:N/2) ) );
title(ham mat do pho nang luong);
xlabel (f);
ylabel (db);
Kt qu

BI S 3:
M NG DY NRZ
3.1 M phng h thng truyn s dn bng tn c s s dng phng php m ha
NRZ lng cc (BPSK)
Chng trnh:
N = 10^6
ip = rand(1,N)>0.5;
s = 2*ip-1;
n = 1/sqrt(2)*[randn(1,N) + j*randn(1,N)];
SNR = 0:2:6;
for i = 1:length(SNR)
y = s + 10^(-SNR(i)/20)*n;
ipHat = real(y)>0;
c(i) = size(find([ip- ipHat]),2);
end
BER = c/N;
theoryBer = 0.5*erfc(sqrt(10.^(SNR/10)));
semilogy(SNR,BER,'b.-');
xlabel('Eb/No, dB');
ylabel('Bit Error Rate');
title('Bit error probability curve for BPSK modulation');
kt qu

3.2 So snh t l bt li BER thu c v l thuyt


Chng trnh:
SNR_db=0:6;
SNR_dn_simulation=0:2:6;
for i=1:length(SNR_db)
SNR(i)=10^(SNR_db(i)/10);
gama_b(i)=SNR(i);
p(i)=1/2*[1-erf(1/sqrt(2)*sqrt(gama_b(i)))];
end
semilogy(SNR_db,p,'ro--')
xlabel('SNR');
ylabel('P');
title('loi BER thuyet');
Kt qu:

Biu din trn cng th:

BI S 4: IU CH QPSK
4.1 biu chm sao ca tn hiu iu ch QPSK m ha theo m gray
Chng trnh:
x=round(rand(1,10000));
plot(x);
for i=1:2:length(x)
if x(i)==0&x(i+1)==0
s((i+1)/2)=exp(j*pi/4);
elseif x(i)==0&x(i+1)==1;
s((i+1)/2)=exp(j*3*pi/4);
elseif x(i)==1&x(i+1)==1;
s((i+1)/2)=exp(j*5*pi/4);
elseif x(i)==1&x(i+1)==0;
s((i+1)/2)=exp(j*7*pi/4);
end
end
save ex3p1_res s x;
plot(s,'*');
hold on;
t=0:0.01:2*pi;
plot(exp(j*t),'r--');
xlabel('\phi(t)');
ylabel('s_m');
title('bieu do khong gian tin hieu phuc cua tin hieu dieu che QPSK');
Kt qu:

b ie u d o k h o n g g ia n t in h ie u p h u c c u a t in h ie u d ie u c h e Q P S K
1

0 .8

0 .6

0 .4

sm

0 .2

-0 .2

-0 .4

-0 .6

-0 .8

-1
-1

-0 .8

-0 .6

-0 .4

-0 .2

0
( t )

0 .2

0 .4

4.2.cho tn hiu trn qua knh nhiu trng AWGN


Chng trnh:
load ex3p1_res;
es=var(s);
eb=es/2;
snr_db=6;
n_0=eb/10^(snr_db/10);
n=sqrt(n_0/2)*(randn(size(s))+j*randn(size(s)));
r=s+n;

0 .6

0 .8

plot(r,'.');
hold on;
plot(s,'r*');
hold on;
t=0:0.01:2*pi;
plot(exp(j*t),'r--');
legend('s_m','s');
xlabel('I');
ylabel('Q');
title('bieu do khong gian tin hieu phuc');
Kt qu :
b ie u d o k h o n g g ia n t in h ie u p h u c
2
s

s
1 .5

0 .5

-0 .5

-1

-1 .5

-2
-2

-1 .5

-1

-0 .5

0
I

0 .5

1 .5

BI S 5 :
M PHNG H THNG TRUYN DN BNG TN C S
chng trnh:
function y=cha1(SNR_db,S,x)
Es=var(S);
Eb=Es/2;
N_0=Eb/10^(SNR_db/10);
N0=sqrt(N_0/2)*(randn(size(S))+j*randn(size(S)));
NS=S+N0;
theta_m=[pi/4,3*pi/4,5*pi/4,7*pi/4];
S_m=exp(j*theta_m);
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;
for i=1:length(x)
if R(i)~=x(i);
c=c+1;
end
end
y=c;
clear all
load ex5p1_Res S x;

SNR_db=0:2:8;
for i=1:length(SNR_db)
c(i)=cha(SNR_db(i),S,x);
end
BEP=c/length(x);
semilogy(SNR_db,BEP,'.--');
save ex6p1_Res c BEP;
Kt qu:

BI S 6:
Tnh t l li bit l thuyt
Chng trnh:
SNR_db=0:8;
SNR_db_simulation=0:2:8;
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;
end
semilogy(SNR_db,p_b,'ro--')
hold on
load ex6p1_Res c BEP;
semilogy(SNR_db_simulation,BEP,'x--')
title('cac xac suat loi bit');
xlabel('SNR in dB');
ylabel('P_b');
legend('Theory','Simulation');
hold off
Kt qu:

También podría gustarte