Professional Documents
Culture Documents
Code
step = 0.1; x= -5:step:5; px = (1/sqrt(2*pi))*exp(-x.^2/2); plot(x,px); xlabel('x'); ylabel('P(x)'); title('do thi phan bo xac suat Gauss');
% % % %
Hnh v m phng
do thi phan bo xac suat Gauss 0.4
0.35
0.3
0.25
P(x)
0.2
0.15
0.1
0.05
0 -5
-4
-3
-2
-1
0 x
Hnh v m phng
Phan bo xac suat Gauss 0.45 0.4 0.35 0.3 0.25 ly thuyet mo phong
y
0.2 0.15 0.1 0.05 0 -5
-4
-3
-2
-1
0 x
Hnh m phng
Hnh m phng
Bi s 3. M ng dy NRZ
3.1. H thng truyn s dn bng tn c s Code
len = 10^5 ; bsignal = randint(1,len); % tao mot vecto len bit ngau nhien NRZ_signal = 2*bsignal-1; % dieu che BPSK, u noise = 1/sqrt(2)*[randn(1,len)]; % tao mot nhieu phuc Gauss SNR_db = 0:2:8; % ti le tin hieu tren tap am [dB] for i = 1:length(SNR_db) NRZ_rsignal = NRZ_signal + 10^(-SNR_db(i)/20)*noise; % cong nhieu trang NRZ_decoded = sign(NRZ_rsignal)>0; % ki hieu thu duoc c(i) = nnz([bsignal- NRZ_decoded]); end BER = c/len; theoryBer = 0.5*erfc(sqrt(10.^(SNR_db/10))); % xac suut loi bit ly thuyet save bpsk BER; % luu file de phuc vu Bai 3.2 semilogy(SNR_db,BER,'b.-'); xlabel('SNR_db[dB]'); ylabel('BER');
Hnh m phng
Hnh m phng
Bi s 4. iu ch QPSK
4.1. Biu chm sao ca tn hiu iu ch QPSK v m ha theo m Gray Code
clear; x = randint(1,100000); % tao bien ngau nhieu 0 va 1 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 ex5p1_res s x; plot(s,'o'); hold on; t = 0:0.01:2*pi; plot(exp(j*t),'r--'); % luu bai lai dung cho bai sau
Hnh m phng
4.2. Cho tn hiu trn qua knh nhiu trng AWGN Code
clear; load ex5p1_res; es = var(s); eb = es/2; snr_db = 6; % gia thiet n_0 = eb/10^(snr_db/10); n = sqrt(n_0/2)*(randn(size(s)) + j*randn(size(s))); % mien nhieu gauss r = s + n; plot(r,'.'); hold on; plot(s,'r*'); hold on; % tin hieu cong nhieu %load phan da luu o bai 4
Hnh m phng
% tra ve y
% Main function: clear all load Bai4p1 s x % load file exp5p1_Res c luu Bai 4.1 SNR_db = 0:2:8; % vong lap xac dinh so loi bit ung voi gia tri SNR[dB] khac nhau for i = 1:length(SNR_db) c(i) = cha(SNR_db(i),s,x); end BEP = c/length(x); % xac suat loi bit semilogy(SNR_db,BEP,'.--'); % ve do thi net '.--' title('Do thi ti le loi bit voi ti le tin hieu tren nhieu'); xlabel('SNR[dB]'); ylabel('Pb'); save Bai5 c BEP;
Hnh m phng
10
-2
Pb
10
-3
10
-4
4 SNR[dB]
10
11