SlideShare a Scribd company logo
1 of 17
ĐẠI HỌC BÁCH KHOA HÀ NỘI
VIỆN ĐIỆN TỬ VIỄN THÔNG
----------
BÁO CÁO THÍ NGHIỆM
THÔNG TIN SỐ
Mã nguồn MATLAB và kết quả mô phỏng
Giảng viên hướng dẫn: Trần Ngọc Tuấn
Sinh viên thực hiện: Nguyễn Minh Đan
MSSV: 20183876
Lớp: CTTN Điện tử truyền thông K63
Mã môn học: ET3250
Nhóm thí nghiệm: TN02
Hà Nội, 07-2021
1
Bài 1. Mô phỏng nhiễu Gauss
% Bai 1.1
x=-5:0.1:5;
Px=(1/(sqrt(2*pi))*exp(-x.^2/2));
plot(x,Px);
% Bai 1.2
len=100000;
x=randn(1,len);
step=.1;
k=-10:step:10;
px=hist(x,k)/len/step;
stem(k,px);
px_lithuyet=exp(-k.^2/2)/sqrt(2*pi);
hold on;
plot(k,px_lithuyet);
title(' Phan bo xac suat Gauss ');
xlabel('x');
ylabel('P(x)');
2
legend('Mo phong', 'Ly thuyet');
hold off;
Bài 2. Kỹ thuật lượng tử hóa tuyến tính
% Ham Linear Quantization - Luong tu hoa tuyen tinh
function [indx, qy] = lquan(x,xmin,xmax,nbit)
nlevel=2^nbit; % So muc luong tu hoa
q=(xmax-xmin)/nlevel; % Buoc luong tu
[indx, qy] = quantiz(x,xmin+q:q:xmax-q,xmin+q/2:q:xmax-q/2);
end
% Bai 2.2
t=0:.01:20;
xt = sin(randn()+t).*cos(rand()*t);
3
[inx, xqt] = lquan(xt,-1,1,randi(3)+1);
plot(t,xt,'b',t,xqt,'r');
title('Luong tu hoa tuyen tinh tin hieu');
xlabel('t');
ylabel('x(t) va xq(t)');
legend('x(t)','xq(t)');
grid on;
Bài 3. Tạp âm lượng tử trong kỹ thuật lượng tử hóa tuyến tính
% Bai 3
N = 1000;
x_uni = 2*rand(1,N)-1;
x_sin = sin(linspace(1,5,N));
nbit = 1:10;
SNqR_uni = zeros(size(nbit));
4
SNqR_sin = zeros(size(nbit));
SNqR_lt = 6.02*nbit;
Ps_uni = sum(x_uni.^2)/N;
Ps_sin = sum(x_sin.^2)/N;
for i=1:size(nbit,2)
[indx1, qy1] = lquan(x_uni,-1,1,nbit(i));
[indx2, qy2] = lquan(x_sin,-1,1,nbit(i));
eq_uni = x_uni-qy1;
eq_sin = x_sin-qy2;
Pq_uni = (1/N)*sum(abs(eq_uni).^2);
Pq_sin = (1/N)*sum(abs(eq_sin).^2);
SNqR_uni(i)=10*log10(Ps_uni/Pq_uni);
SNqR_sin(i)=10*log10(Ps_sin/Pq_sin);
end
stem(nbit,SNqR_uni, 'b'); % blue
hold on;
stem(nbit,SNqR_sin,'r'); % red
hold on;
stem(nbit,SNqR_lt,'m'); % magenta
xlabel('nbit');
ylabel('SNqR');
title('Ty so tin hieu tren tap am luong tu trong luong tu hoa tuyen tinh')
legend('SNqR_u_n_i','SNqR_s_i_n','SNqR_l_t', 'Location', 'northwest');
5
Bài 4. Mật độ phổ năng lượng và hàm tự tương quan của tín hiệu
% Bai 4.1
L = 500;
x = randn(1,L); % TH 1
% x = linspace(-1,1,L); % TH 2
% x = sin(linspace(-10,10,L)); % TH 3
acorr_x = xcorr(x);
n = -(L-1):L-1;
plot(n,acorr_x);
title('Do thi ham tu tuong quan');
xlabel('x');
ylabel('r_x_x');
6
7
% Bai 4.2
L = 50; % Do dai tin hieu
N = 200; % So luong cac tan so roi rac trong khoang 0 den 2*pi
x = rand(1,L); % Tao tin hieu ngau nhien
w = linspace(0,2*pi,N); % Tao N tan so tang dan tu 0 den 2*pi
fx = freqz(x,1,w); % Bien doi Fourier cua x tai cac tan so roi rac
esd_x = fx.*conj(fx); % Tinh ham mat do pho nang luong
acorr_x = xcorr(x); % Tinh ham tu tuong quan cua tin hieu x
ft_acorr_x = freqz(acorr_x,1,w).*exp(j*w*(L-1)); % Bien doi Fourier cua
ham tu tuong quan cua tin hieu x
% Ve do thi
subplot(2,1,1);
semilogy(w/pi,esd_x);
title('Do thi mat do pho nang luong');
xlabel('w');
8
ylabel('S(e^j^omega)')
hold on;
subplot(2,1,2);
semilogy(w/pi,real(ft_acorr_x),'r');
title('Do thi pho ham tu tuong quan');
xlabel('w');
ylabel('R_x_x(e^j^omega)');
hold off;
9
Bài 5. Mã đường dây NRZ
% Bai 5
len = 100000; % Do dai dong bit mo phong
SNR_db = 0:2:8; % Tao vector SNR_db = 0 2 4 6 8
SNR = 10.^(SNR_db/10); % Doi SNR tu Decibel sang lan
bsignal = randi([0 1],1,len); % Dong bit ngau nhien voi do dai len
NRZ_signal = bsignal*2-1; % Bien doi dong bit 0 1 sang -1 1
N0 = 1./SNR; % Cong suat tap am
for i=1:length(SNR_db)
noise = sqrt(N0(i))*randn(1,len); % Tao tap am noise voi ti so SNR(i)
r_signal = NRZ_signal + noise; % Tin hieu thu duoc = NRZ + noise
NRZ_decoded = sign(r_signal); % Giai ma tin hieu NRZ thu duoc
[n,BER(i)] = symerr(NRZ_decoded,NRZ_signal); % Tinh xac suat loi
end
plot(SNR_db,BER,'bo--');
Pe = 1/2*(1-erf(sqrt(SNR)/sqrt(2))); % Xac suat loi theo ly thuyet
hold on;
plot(SNR_db,Pe,'r*--'); % Ve do thi Pe
title('Do thi ty le loi bit BER theo ly thuyet va mo phong');
xlabel('SNR_d_B');
ylabel('BER');
legend('Mo phong','Ly thuyet');
10
Bài 6. Kỹ thuật điều chế số QPSK
% Bai 6
len = 50000; % Do dai dong bit mo phong
SNR_db = 0; % SNR co don vi Decibel
% SNR_db = 3; % Thay doi SNR = 3 dB
% SNR_db = 6; % Thay doi SNR = 6 dB
SNR = 10^(SNR_db/10); % Doi SNR tu Decibel sang lan
bsignal = randi([0 1],1,len); % Tao dong bit ngau nhien do dai len
% Bat dau thuc hien dieu che QPSK
for i=1:2:len
if bsignal(i)==0 & bsignal(i+1)==0 % cap bit 00
qpsk_signal((i+1)/2) = exp(j*3*pi/4);
elseif bsignal(i)==0 & bsignal(i+1)==1 % cap bit 01
qpsk_signal((i+1)/2) = exp(j*5*pi/4);
11
elseif bsignal(i)==1 & bsignal(i+1)==1 % cap bit 11
qpsk_signal((i+1)/2) = exp(j*7*pi/4);
elseif bsignal(i)==1 & bsignal(i+1)==0 % cap bit 10
qpsk_signal((i+1)/2) = exp(j*pi/4);
end
end
Es = std(qpsk_signal)^2; % Nang luong ky hieu
N0 = Es/SNR; % Cong suat tap am
% Tao nhieu Gauss
noise =
sqrt(N0/2)*(randn(1,length(qpsk_signal))+j*randn(1,length(qpsk_signal)));
qpsk_awgn = qpsk_signal + noise; % Cho tin hieu dieu che di qua kenh AWGN
plot(qpsk_awgn,'.'); % Ve chom sao tin hieu co nhieu
title('Do thi chom sao 4-QPSK (SNR=0dB)');
xlabel('I');
ylabel('Q');
hold on;
plot(qpsk_signal,'r*'); % Ve chom sao tin hieu khong nhieu
plot(exp(j*[0:0.01:2*pi]),'r--');
12
13
Bài 7. Xác suất lỗi bit trong điều chế QPSK
% Bai 7
len = 50000; % Do dai dong bit mo phong
SNR_db = 0:2:8; % Tao vector SNR_db = 0 2 4 6 8
SNR = 10.^(SNR_db/10); % Doi SNR tu Decibel sang lan
bsignal = randi([0 1],1,len); % Tao dong bit ngau nhien do dai len
% Thuc hien dieu che QPSK
for i=1:2:len
if bsignal(i)==0 & bsignal(i+1)==0 % cap bit 00
qpsk_signal((i+1)/2) = exp(j*3*pi/4);
elseif bsignal(i)==0 & bsignal(i+1)==1 % cap bit 01
qpsk_signal((i+1)/2) = exp(j*5*pi/4);
elseif bsignal(i)==1 & bsignal(i+1)==1 % cap bit 11
qpsk_signal((i+1)/2) = exp(j*7*pi/4);
elseif bsignal(i)==1 & bsignal(i+1)==0 % cap bit 10
qpsk_signal((i+1)/2) = exp(j*pi/4);
end
end
% Tim BER mo phong
for i=1:length(SNR_db)
r_signal = awgn(qpsk_signal,SNR_db(i)); % Dieu che QPSK di qua nhieu AWGN
for j=1:2:len % Giai dieu che tin hieu QPSK co nhieu
if real(r_signal((j+1)/2))>=0
if imag(r_signal((j+1)/2))>=0 % Goc phan tu I
r_bsignal(j) = 1;
r_bsignal(j+1) = 0;
else % Goc phan tu IV
r_bsignal(j) = 1;
r_bsignal(j+1) = 1;
end
else
if imag(r_signal((j+1)/2))>=0 % Goc phan tu II
r_bsignal(j) = 0;
r_bsignal(j+1) = 0;
else % Goc phan tu III
r_bsignal(j) = 0;
r_bsignal(j+1) = 1;
end
end
14
end
[n,BER(i)] = biterr(r_bsignal,bsignal);
end
Pb = 1/2*erfc(1/sqrt(2).*sqrt(SNR)); % Xac suat loi bit
plot(SNR_db,Pb,'ro--'); % Ve do thi Pb ly thuyet
title('Do thi ty le bit loi BER ly thuyet va mo phong');
xlabel('SNR_d_B');
ylabel('BER');
hold on;
plot(SNR_db,BER); % Ve do thi BER mo phong
legend('Ly thuyet','Mo phong');
hold off;
15
Bài 8. Mô phỏng điều chế M-QAM qua kênh nhiễu Gauss
% Bai 8.1
n_sym = 50000; % So ky tu dieu che
M = [16 64 256]; % So symbol ky hieu
SNR_db = 0:25; % Tao vector SNR = 0 - 25 Decibel
BER = zeros(length(M),length(SNR_db)); % BER de luu ti le loi bit
for k = 1:size(M,2) % size(M,2) la so cot cua M
s_stream = randi([0 M(k)-1],1,n_sym); % Tao dong bieu tuong do
dai n_sym
s_mod = qammod(s_stream,M(k),'GRAY'); % Dieu che M-QAM
for r = 1:size(SNR_db,2) % Vong lap tinh BER
s_mod_awgn = awgn(s_mod,SNR_db(r),'measured'); % Tin hieu qua nhieu
s_demod = qamdemod(s_mod_awgn,M(k),'GRAY'); % Giai dieu che M-QAM
[num, ratio] = biterr(s_stream,s_demod); % Tinh ti le loi bit
BER(k,r) = ratio; % Luu ti le loi bit vao BER
end
end
semilogy(SNR_db,BER(1,:),'gx', 'LineStyle', 'none'); % Ve do thi BER voi M
= 16
hold on;
semilogy(SNR_db,BER(2,:),'ro', 'LineStyle', 'none'); % Ve do thi BER voi M
= 64
semilogy(SNR_db,BER(3,:),'b*', 'LineStyle', 'none'); % Ve do thi BER voi M
= 256
grid on;
BER_lt = zeros(length(M),length(SNR_db));
for i = 1:length(M)
BER_lt(i,:) = berawgn(SNR_db - 10*log10(log2(M(i))),'qam',M(i));
end
semilogy(SNR_db,BER_lt(1,:),'g-'); % Ve do thi BER ly
thuyet voi M = 16
semilogy(SNR_db,BER_lt(2,:),'r-'); % Ve do thi BER ly
thuyet voi M = 64
semilogy(SNR_db,BER_lt(3,:),'b-'); % Ve do thi BER ly
thuyet voi M = 256
title('Do thi ty le loi bit mo phong va ly thuyet cua ky thuat M-QAM');
xlabel('SNR_d_B');
16
ylabel('BER/Pe');
legend('BER 16-QAM','BER 64-QAM','BER 256-QAM','Pe 16-QAM','Pe 64-QAM','Pe
256-QAM', 'Location', 'southwest');
hold off;

More Related Content

What's hot (6)

Ch 04 Arithmetic Coding (Ppt)
Ch 04 Arithmetic Coding (Ppt)Ch 04 Arithmetic Coding (Ppt)
Ch 04 Arithmetic Coding (Ppt)
 
06 Arithmetic 1
06 Arithmetic 106 Arithmetic 1
06 Arithmetic 1
 
Digfilt
DigfiltDigfilt
Digfilt
 
Simulation of a_pmsm_motor_control_system
Simulation of a_pmsm_motor_control_systemSimulation of a_pmsm_motor_control_system
Simulation of a_pmsm_motor_control_system
 
Matlab 2
Matlab 2Matlab 2
Matlab 2
 
Matlab programs
Matlab programsMatlab programs
Matlab programs
 

Similar to Tb16 nguyễn minhđan_20183876

Please use the same variables and only write the TODO part #!-usr-bi.pdf
Please use the same variables and only write the TODO part   #!-usr-bi.pdfPlease use the same variables and only write the TODO part   #!-usr-bi.pdf
Please use the same variables and only write the TODO part #!-usr-bi.pdf
asenterprisestyagi
 
Use the same variable names and write the function F - Force(x-ks-kc-l.pdf
Use the same variable names and write the function F - Force(x-ks-kc-l.pdfUse the same variable names and write the function F - Force(x-ks-kc-l.pdf
Use the same variable names and write the function F - Force(x-ks-kc-l.pdf
acteleshoppe
 
Fourier series example
Fourier series exampleFourier series example
Fourier series example
Abi finni
 
Digitla Communication pulse shaping filter
Digitla Communication pulse shaping filterDigitla Communication pulse shaping filter
Digitla Communication pulse shaping filter
mirfanjum
 
Matlab kod taslağı
Matlab kod taslağıMatlab kod taslağı
Matlab kod taslağı
Merve Cvdr
 
Experiment3_DCS-21BEC0384Adityabonnerjee
Experiment3_DCS-21BEC0384AdityabonnerjeeExperiment3_DCS-21BEC0384Adityabonnerjee
Experiment3_DCS-21BEC0384Adityabonnerjee
AdityaBonnerjee21BEC
 

Similar to Tb16 nguyễn minhđan_20183876 (20)

Please use the same variables and only write the TODO part #!-usr-bi.pdf
Please use the same variables and only write the TODO part   #!-usr-bi.pdfPlease use the same variables and only write the TODO part   #!-usr-bi.pdf
Please use the same variables and only write the TODO part #!-usr-bi.pdf
 
Use the same variable names and write the function F - Force(x-ks-kc-l.pdf
Use the same variable names and write the function F - Force(x-ks-kc-l.pdfUse the same variable names and write the function F - Force(x-ks-kc-l.pdf
Use the same variable names and write the function F - Force(x-ks-kc-l.pdf
 
QFSK: BER and SER Derivation and Simulation
QFSK: BER and SER Derivation and SimulationQFSK: BER and SER Derivation and Simulation
QFSK: BER and SER Derivation and Simulation
 
Section6 stochastic
Section6 stochasticSection6 stochastic
Section6 stochastic
 
Fourier series example
Fourier series exampleFourier series example
Fourier series example
 
The Moore-Spiegel Oscillator
The Moore-Spiegel OscillatorThe Moore-Spiegel Oscillator
The Moore-Spiegel Oscillator
 
Digitla Communication pulse shaping filter
Digitla Communication pulse shaping filterDigitla Communication pulse shaping filter
Digitla Communication pulse shaping filter
 
matlab.docx
matlab.docxmatlab.docx
matlab.docx
 
Computational Method to Solve the Partial Differential Equations (PDEs)
Computational Method to Solve the Partial Differential  Equations (PDEs)Computational Method to Solve the Partial Differential  Equations (PDEs)
Computational Method to Solve the Partial Differential Equations (PDEs)
 
Main code
Main codeMain code
Main code
 
Matlab kod taslağı
Matlab kod taslağıMatlab kod taslağı
Matlab kod taslağı
 
Numerical methods generating polynomial
Numerical methods generating polynomialNumerical methods generating polynomial
Numerical methods generating polynomial
 
EEL316: CDMA with DSSS
EEL316: CDMA with DSSSEEL316: CDMA with DSSS
EEL316: CDMA with DSSS
 
bask, bfsk, bpsk
bask, bfsk, bpskbask, bfsk, bpsk
bask, bfsk, bpsk
 
EEL316: ASK
EEL316: ASKEEL316: ASK
EEL316: ASK
 
Experiment3_DCS-21BEC0384Adityabonnerjee
Experiment3_DCS-21BEC0384AdityabonnerjeeExperiment3_DCS-21BEC0384Adityabonnerjee
Experiment3_DCS-21BEC0384Adityabonnerjee
 
Dsp manual
Dsp manualDsp manual
Dsp manual
 
Modulation techniques matlab_code
Modulation techniques matlab_codeModulation techniques matlab_code
Modulation techniques matlab_code
 
A MODIFIED DIRECTIONAL WEIGHTED CASCADED-MASK MEDIAN FILTER FOR REMOVAL OF RA...
A MODIFIED DIRECTIONAL WEIGHTED CASCADED-MASK MEDIAN FILTER FOR REMOVAL OF RA...A MODIFIED DIRECTIONAL WEIGHTED CASCADED-MASK MEDIAN FILTER FOR REMOVAL OF RA...
A MODIFIED DIRECTIONAL WEIGHTED CASCADED-MASK MEDIAN FILTER FOR REMOVAL OF RA...
 
Cs580
Cs580Cs580
Cs580
 

More from NgGiaHi

More from NgGiaHi (11)

Toan hn de_full
Toan hn de_fullToan hn de_full
Toan hn de_full
 
Toan hn de_1-13
Toan hn de_1-13Toan hn de_1-13
Toan hn de_1-13
 
Toan hn da_full
Toan hn da_fullToan hn da_full
Toan hn da_full
 
Toán hn 2021
Toán hn 2021Toán hn 2021
Toán hn 2021
 
Toán hn 2020
Toán hn 2020Toán hn 2020
Toán hn 2020
 
Slide nhom07
Slide nhom07Slide nhom07
Slide nhom07
 
Ltmmsdsds
LtmmsdsdsLtmmsdsds
Ltmmsdsds
 
Learn aessdsds
Learn aessdsdsLearn aessdsds
Learn aessdsds
 
Bài tập condition 1
Bài tập condition 1 Bài tập condition 1
Bài tập condition 1
 
Tb16 nguyễn minhđan_20183876
Tb16 nguyễn minhđan_20183876Tb16 nguyễn minhđan_20183876
Tb16 nguyễn minhđan_20183876
 
Bài tập condition 1
Bài tập condition 1 Bài tập condition 1
Bài tập condition 1
 

Recently uploaded

obat aborsi gresik wa 081336238223 jual obat aborsi cytotec asli di gresik782...
obat aborsi gresik wa 081336238223 jual obat aborsi cytotec asli di gresik782...obat aborsi gresik wa 081336238223 jual obat aborsi cytotec asli di gresik782...
obat aborsi gresik wa 081336238223 jual obat aborsi cytotec asli di gresik782...
yulianti213969
 
如何办理(USC毕业证书)南加利福尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(USC毕业证书)南加利福尼亚大学毕业证成绩单本科硕士学位证留信学历认证如何办理(USC毕业证书)南加利福尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(USC毕业证书)南加利福尼亚大学毕业证成绩单本科硕士学位证留信学历认证
gakamzu
 
Prest Reed Portfolio revamp Full Sail Presentation 2
Prest Reed Portfolio revamp Full Sail Presentation 2Prest Reed Portfolio revamp Full Sail Presentation 2
Prest Reed Portfolio revamp Full Sail Presentation 2
5203records
 
b-sc-agri-course-curriculum.pdf for Karnataka state board
b-sc-agri-course-curriculum.pdf for Karnataka state boardb-sc-agri-course-curriculum.pdf for Karnataka state board
b-sc-agri-course-curriculum.pdf for Karnataka state board
ramyaul734
 
一比一原版赫尔大学毕业证如何办理
一比一原版赫尔大学毕业证如何办理一比一原版赫尔大学毕业证如何办理
一比一原版赫尔大学毕业证如何办理
F
 
obat aborsi pacitan wa 081336238223 jual obat aborsi cytotec asli di pacitan0...
obat aborsi pacitan wa 081336238223 jual obat aborsi cytotec asli di pacitan0...obat aborsi pacitan wa 081336238223 jual obat aborsi cytotec asli di pacitan0...
obat aborsi pacitan wa 081336238223 jual obat aborsi cytotec asli di pacitan0...
yulianti213969
 
如何办理(TMU毕业证书)多伦多都会大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(TMU毕业证书)多伦多都会大学毕业证成绩单本科硕士学位证留信学历认证如何办理(TMU毕业证书)多伦多都会大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(TMU毕业证书)多伦多都会大学毕业证成绩单本科硕士学位证留信学历认证
gkyvm
 
如何办理(Columbia毕业证书)哥伦比亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(Columbia毕业证书)哥伦比亚大学毕业证成绩单本科硕士学位证留信学历认证如何办理(Columbia毕业证书)哥伦比亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(Columbia毕业证书)哥伦比亚大学毕业证成绩单本科硕士学位证留信学历认证
epyhpep
 
一比一原版(UCI毕业证)加州大学欧文分校毕业证成绩单学位证留信学历认证
一比一原版(UCI毕业证)加州大学欧文分校毕业证成绩单学位证留信学历认证一比一原版(UCI毕业证)加州大学欧文分校毕业证成绩单学位证留信学历认证
一比一原版(UCI毕业证)加州大学欧文分校毕业证成绩单学位证留信学历认证
vflw6bsde
 
一比一定(购)南昆士兰大学毕业证(USQ毕业证)成绩单学位证
一比一定(购)南昆士兰大学毕业证(USQ毕业证)成绩单学位证一比一定(购)南昆士兰大学毕业证(USQ毕业证)成绩单学位证
一比一定(购)南昆士兰大学毕业证(USQ毕业证)成绩单学位证
eqaqen
 
一比一定(购)中央昆士兰大学毕业证(CQU毕业证)成绩单学位证
一比一定(购)中央昆士兰大学毕业证(CQU毕业证)成绩单学位证一比一定(购)中央昆士兰大学毕业证(CQU毕业证)成绩单学位证
一比一定(购)中央昆士兰大学毕业证(CQU毕业证)成绩单学位证
eqaqen
 
如何办理(VIU毕业证书)温哥华岛大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(VIU毕业证书)温哥华岛大学毕业证成绩单本科硕士学位证留信学历认证如何办理(VIU毕业证书)温哥华岛大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(VIU毕业证书)温哥华岛大学毕业证成绩单本科硕士学位证留信学历认证
gkyvm
 

Recently uploaded (20)

obat aborsi gresik wa 081336238223 jual obat aborsi cytotec asli di gresik782...
obat aborsi gresik wa 081336238223 jual obat aborsi cytotec asli di gresik782...obat aborsi gresik wa 081336238223 jual obat aborsi cytotec asli di gresik782...
obat aborsi gresik wa 081336238223 jual obat aborsi cytotec asli di gresik782...
 
如何办理(USC毕业证书)南加利福尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(USC毕业证书)南加利福尼亚大学毕业证成绩单本科硕士学位证留信学历认证如何办理(USC毕业证书)南加利福尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(USC毕业证书)南加利福尼亚大学毕业证成绩单本科硕士学位证留信学历认证
 
UIowa Application Instructions - 2024 Update
UIowa Application Instructions - 2024 UpdateUIowa Application Instructions - 2024 Update
UIowa Application Instructions - 2024 Update
 
Prest Reed Portfolio revamp Full Sail Presentation 2
Prest Reed Portfolio revamp Full Sail Presentation 2Prest Reed Portfolio revamp Full Sail Presentation 2
Prest Reed Portfolio revamp Full Sail Presentation 2
 
b-sc-agri-course-curriculum.pdf for Karnataka state board
b-sc-agri-course-curriculum.pdf for Karnataka state boardb-sc-agri-course-curriculum.pdf for Karnataka state board
b-sc-agri-course-curriculum.pdf for Karnataka state board
 
Ganga Path Project (marine drive project) Patna ,Bihar .pdf
Ganga Path Project (marine drive project) Patna ,Bihar .pdfGanga Path Project (marine drive project) Patna ,Bihar .pdf
Ganga Path Project (marine drive project) Patna ,Bihar .pdf
 
一比一原版赫尔大学毕业证如何办理
一比一原版赫尔大学毕业证如何办理一比一原版赫尔大学毕业证如何办理
一比一原版赫尔大学毕业证如何办理
 
obat aborsi pacitan wa 081336238223 jual obat aborsi cytotec asli di pacitan0...
obat aborsi pacitan wa 081336238223 jual obat aborsi cytotec asli di pacitan0...obat aborsi pacitan wa 081336238223 jual obat aborsi cytotec asli di pacitan0...
obat aborsi pacitan wa 081336238223 jual obat aborsi cytotec asli di pacitan0...
 
Crafting an effective CV for AYUSH Doctors.pdf
Crafting an effective CV for AYUSH Doctors.pdfCrafting an effective CV for AYUSH Doctors.pdf
Crafting an effective CV for AYUSH Doctors.pdf
 
如何办理(TMU毕业证书)多伦多都会大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(TMU毕业证书)多伦多都会大学毕业证成绩单本科硕士学位证留信学历认证如何办理(TMU毕业证书)多伦多都会大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(TMU毕业证书)多伦多都会大学毕业证成绩单本科硕士学位证留信学历认证
 
Career counseling presentation for commerce students
Career counseling presentation for commerce studentsCareer counseling presentation for commerce students
Career counseling presentation for commerce students
 
如何办理(Columbia毕业证书)哥伦比亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(Columbia毕业证书)哥伦比亚大学毕业证成绩单本科硕士学位证留信学历认证如何办理(Columbia毕业证书)哥伦比亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(Columbia毕业证书)哥伦比亚大学毕业证成绩单本科硕士学位证留信学历认证
 
TEST BANK For Growth and Development Across the Lifespan, 3rd Edition By Glor...
TEST BANK For Growth and Development Across the Lifespan, 3rd Edition By Glor...TEST BANK For Growth and Development Across the Lifespan, 3rd Edition By Glor...
TEST BANK For Growth and Development Across the Lifespan, 3rd Edition By Glor...
 
Novo Nordisk Kalundborg. We are expanding our manufacturing hub in Kalundborg...
Novo Nordisk Kalundborg. We are expanding our manufacturing hub in Kalundborg...Novo Nordisk Kalundborg. We are expanding our manufacturing hub in Kalundborg...
Novo Nordisk Kalundborg. We are expanding our manufacturing hub in Kalundborg...
 
一比一原版(UCI毕业证)加州大学欧文分校毕业证成绩单学位证留信学历认证
一比一原版(UCI毕业证)加州大学欧文分校毕业证成绩单学位证留信学历认证一比一原版(UCI毕业证)加州大学欧文分校毕业证成绩单学位证留信学历认证
一比一原版(UCI毕业证)加州大学欧文分校毕业证成绩单学位证留信学历认证
 
一比一定(购)南昆士兰大学毕业证(USQ毕业证)成绩单学位证
一比一定(购)南昆士兰大学毕业证(USQ毕业证)成绩单学位证一比一定(购)南昆士兰大学毕业证(USQ毕业证)成绩单学位证
一比一定(购)南昆士兰大学毕业证(USQ毕业证)成绩单学位证
 
Ascension Brown - Internship Resume 2024
Ascension Brown -  Internship Resume 2024Ascension Brown -  Internship Resume 2024
Ascension Brown - Internship Resume 2024
 
一比一定(购)中央昆士兰大学毕业证(CQU毕业证)成绩单学位证
一比一定(购)中央昆士兰大学毕业证(CQU毕业证)成绩单学位证一比一定(购)中央昆士兰大学毕业证(CQU毕业证)成绩单学位证
一比一定(购)中央昆士兰大学毕业证(CQU毕业证)成绩单学位证
 
Launch Your Research Career: A Beginner's Guide
Launch Your Research Career: A Beginner's GuideLaunch Your Research Career: A Beginner's Guide
Launch Your Research Career: A Beginner's Guide
 
如何办理(VIU毕业证书)温哥华岛大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(VIU毕业证书)温哥华岛大学毕业证成绩单本科硕士学位证留信学历认证如何办理(VIU毕业证书)温哥华岛大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(VIU毕业证书)温哥华岛大学毕业证成绩单本科硕士学位证留信学历认证
 

Tb16 nguyễn minhđan_20183876

  • 1. ĐẠI HỌC BÁCH KHOA HÀ NỘI VIỆN ĐIỆN TỬ VIỄN THÔNG ---------- BÁO CÁO THÍ NGHIỆM THÔNG TIN SỐ Mã nguồn MATLAB và kết quả mô phỏng Giảng viên hướng dẫn: Trần Ngọc Tuấn Sinh viên thực hiện: Nguyễn Minh Đan MSSV: 20183876 Lớp: CTTN Điện tử truyền thông K63 Mã môn học: ET3250 Nhóm thí nghiệm: TN02 Hà Nội, 07-2021
  • 2. 1 Bài 1. Mô phỏng nhiễu Gauss % Bai 1.1 x=-5:0.1:5; Px=(1/(sqrt(2*pi))*exp(-x.^2/2)); plot(x,Px); % Bai 1.2 len=100000; x=randn(1,len); step=.1; k=-10:step:10; px=hist(x,k)/len/step; stem(k,px); px_lithuyet=exp(-k.^2/2)/sqrt(2*pi); hold on; plot(k,px_lithuyet); title(' Phan bo xac suat Gauss '); xlabel('x'); ylabel('P(x)');
  • 3. 2 legend('Mo phong', 'Ly thuyet'); hold off; Bài 2. Kỹ thuật lượng tử hóa tuyến tính % Ham Linear Quantization - Luong tu hoa tuyen tinh function [indx, qy] = lquan(x,xmin,xmax,nbit) nlevel=2^nbit; % So muc luong tu hoa q=(xmax-xmin)/nlevel; % Buoc luong tu [indx, qy] = quantiz(x,xmin+q:q:xmax-q,xmin+q/2:q:xmax-q/2); end % Bai 2.2 t=0:.01:20; xt = sin(randn()+t).*cos(rand()*t);
  • 4. 3 [inx, xqt] = lquan(xt,-1,1,randi(3)+1); plot(t,xt,'b',t,xqt,'r'); title('Luong tu hoa tuyen tinh tin hieu'); xlabel('t'); ylabel('x(t) va xq(t)'); legend('x(t)','xq(t)'); grid on; Bài 3. Tạp âm lượng tử trong kỹ thuật lượng tử hóa tuyến tính % Bai 3 N = 1000; x_uni = 2*rand(1,N)-1; x_sin = sin(linspace(1,5,N)); nbit = 1:10; SNqR_uni = zeros(size(nbit));
  • 5. 4 SNqR_sin = zeros(size(nbit)); SNqR_lt = 6.02*nbit; Ps_uni = sum(x_uni.^2)/N; Ps_sin = sum(x_sin.^2)/N; for i=1:size(nbit,2) [indx1, qy1] = lquan(x_uni,-1,1,nbit(i)); [indx2, qy2] = lquan(x_sin,-1,1,nbit(i)); eq_uni = x_uni-qy1; eq_sin = x_sin-qy2; Pq_uni = (1/N)*sum(abs(eq_uni).^2); Pq_sin = (1/N)*sum(abs(eq_sin).^2); SNqR_uni(i)=10*log10(Ps_uni/Pq_uni); SNqR_sin(i)=10*log10(Ps_sin/Pq_sin); end stem(nbit,SNqR_uni, 'b'); % blue hold on; stem(nbit,SNqR_sin,'r'); % red hold on; stem(nbit,SNqR_lt,'m'); % magenta xlabel('nbit'); ylabel('SNqR'); title('Ty so tin hieu tren tap am luong tu trong luong tu hoa tuyen tinh') legend('SNqR_u_n_i','SNqR_s_i_n','SNqR_l_t', 'Location', 'northwest');
  • 6. 5 Bài 4. Mật độ phổ năng lượng và hàm tự tương quan của tín hiệu % Bai 4.1 L = 500; x = randn(1,L); % TH 1 % x = linspace(-1,1,L); % TH 2 % x = sin(linspace(-10,10,L)); % TH 3 acorr_x = xcorr(x); n = -(L-1):L-1; plot(n,acorr_x); title('Do thi ham tu tuong quan'); xlabel('x'); ylabel('r_x_x');
  • 7. 6
  • 8. 7 % Bai 4.2 L = 50; % Do dai tin hieu N = 200; % So luong cac tan so roi rac trong khoang 0 den 2*pi x = rand(1,L); % Tao tin hieu ngau nhien w = linspace(0,2*pi,N); % Tao N tan so tang dan tu 0 den 2*pi fx = freqz(x,1,w); % Bien doi Fourier cua x tai cac tan so roi rac esd_x = fx.*conj(fx); % Tinh ham mat do pho nang luong acorr_x = xcorr(x); % Tinh ham tu tuong quan cua tin hieu x ft_acorr_x = freqz(acorr_x,1,w).*exp(j*w*(L-1)); % Bien doi Fourier cua ham tu tuong quan cua tin hieu x % Ve do thi subplot(2,1,1); semilogy(w/pi,esd_x); title('Do thi mat do pho nang luong'); xlabel('w');
  • 9. 8 ylabel('S(e^j^omega)') hold on; subplot(2,1,2); semilogy(w/pi,real(ft_acorr_x),'r'); title('Do thi pho ham tu tuong quan'); xlabel('w'); ylabel('R_x_x(e^j^omega)'); hold off;
  • 10. 9 Bài 5. Mã đường dây NRZ % Bai 5 len = 100000; % Do dai dong bit mo phong SNR_db = 0:2:8; % Tao vector SNR_db = 0 2 4 6 8 SNR = 10.^(SNR_db/10); % Doi SNR tu Decibel sang lan bsignal = randi([0 1],1,len); % Dong bit ngau nhien voi do dai len NRZ_signal = bsignal*2-1; % Bien doi dong bit 0 1 sang -1 1 N0 = 1./SNR; % Cong suat tap am for i=1:length(SNR_db) noise = sqrt(N0(i))*randn(1,len); % Tao tap am noise voi ti so SNR(i) r_signal = NRZ_signal + noise; % Tin hieu thu duoc = NRZ + noise NRZ_decoded = sign(r_signal); % Giai ma tin hieu NRZ thu duoc [n,BER(i)] = symerr(NRZ_decoded,NRZ_signal); % Tinh xac suat loi end plot(SNR_db,BER,'bo--'); Pe = 1/2*(1-erf(sqrt(SNR)/sqrt(2))); % Xac suat loi theo ly thuyet hold on; plot(SNR_db,Pe,'r*--'); % Ve do thi Pe title('Do thi ty le loi bit BER theo ly thuyet va mo phong'); xlabel('SNR_d_B'); ylabel('BER'); legend('Mo phong','Ly thuyet');
  • 11. 10 Bài 6. Kỹ thuật điều chế số QPSK % Bai 6 len = 50000; % Do dai dong bit mo phong SNR_db = 0; % SNR co don vi Decibel % SNR_db = 3; % Thay doi SNR = 3 dB % SNR_db = 6; % Thay doi SNR = 6 dB SNR = 10^(SNR_db/10); % Doi SNR tu Decibel sang lan bsignal = randi([0 1],1,len); % Tao dong bit ngau nhien do dai len % Bat dau thuc hien dieu che QPSK for i=1:2:len if bsignal(i)==0 & bsignal(i+1)==0 % cap bit 00 qpsk_signal((i+1)/2) = exp(j*3*pi/4); elseif bsignal(i)==0 & bsignal(i+1)==1 % cap bit 01 qpsk_signal((i+1)/2) = exp(j*5*pi/4);
  • 12. 11 elseif bsignal(i)==1 & bsignal(i+1)==1 % cap bit 11 qpsk_signal((i+1)/2) = exp(j*7*pi/4); elseif bsignal(i)==1 & bsignal(i+1)==0 % cap bit 10 qpsk_signal((i+1)/2) = exp(j*pi/4); end end Es = std(qpsk_signal)^2; % Nang luong ky hieu N0 = Es/SNR; % Cong suat tap am % Tao nhieu Gauss noise = sqrt(N0/2)*(randn(1,length(qpsk_signal))+j*randn(1,length(qpsk_signal))); qpsk_awgn = qpsk_signal + noise; % Cho tin hieu dieu che di qua kenh AWGN plot(qpsk_awgn,'.'); % Ve chom sao tin hieu co nhieu title('Do thi chom sao 4-QPSK (SNR=0dB)'); xlabel('I'); ylabel('Q'); hold on; plot(qpsk_signal,'r*'); % Ve chom sao tin hieu khong nhieu plot(exp(j*[0:0.01:2*pi]),'r--');
  • 13. 12
  • 14. 13 Bài 7. Xác suất lỗi bit trong điều chế QPSK % Bai 7 len = 50000; % Do dai dong bit mo phong SNR_db = 0:2:8; % Tao vector SNR_db = 0 2 4 6 8 SNR = 10.^(SNR_db/10); % Doi SNR tu Decibel sang lan bsignal = randi([0 1],1,len); % Tao dong bit ngau nhien do dai len % Thuc hien dieu che QPSK for i=1:2:len if bsignal(i)==0 & bsignal(i+1)==0 % cap bit 00 qpsk_signal((i+1)/2) = exp(j*3*pi/4); elseif bsignal(i)==0 & bsignal(i+1)==1 % cap bit 01 qpsk_signal((i+1)/2) = exp(j*5*pi/4); elseif bsignal(i)==1 & bsignal(i+1)==1 % cap bit 11 qpsk_signal((i+1)/2) = exp(j*7*pi/4); elseif bsignal(i)==1 & bsignal(i+1)==0 % cap bit 10 qpsk_signal((i+1)/2) = exp(j*pi/4); end end % Tim BER mo phong for i=1:length(SNR_db) r_signal = awgn(qpsk_signal,SNR_db(i)); % Dieu che QPSK di qua nhieu AWGN for j=1:2:len % Giai dieu che tin hieu QPSK co nhieu if real(r_signal((j+1)/2))>=0 if imag(r_signal((j+1)/2))>=0 % Goc phan tu I r_bsignal(j) = 1; r_bsignal(j+1) = 0; else % Goc phan tu IV r_bsignal(j) = 1; r_bsignal(j+1) = 1; end else if imag(r_signal((j+1)/2))>=0 % Goc phan tu II r_bsignal(j) = 0; r_bsignal(j+1) = 0; else % Goc phan tu III r_bsignal(j) = 0; r_bsignal(j+1) = 1; end end
  • 15. 14 end [n,BER(i)] = biterr(r_bsignal,bsignal); end Pb = 1/2*erfc(1/sqrt(2).*sqrt(SNR)); % Xac suat loi bit plot(SNR_db,Pb,'ro--'); % Ve do thi Pb ly thuyet title('Do thi ty le bit loi BER ly thuyet va mo phong'); xlabel('SNR_d_B'); ylabel('BER'); hold on; plot(SNR_db,BER); % Ve do thi BER mo phong legend('Ly thuyet','Mo phong'); hold off;
  • 16. 15 Bài 8. Mô phỏng điều chế M-QAM qua kênh nhiễu Gauss % Bai 8.1 n_sym = 50000; % So ky tu dieu che M = [16 64 256]; % So symbol ky hieu SNR_db = 0:25; % Tao vector SNR = 0 - 25 Decibel BER = zeros(length(M),length(SNR_db)); % BER de luu ti le loi bit for k = 1:size(M,2) % size(M,2) la so cot cua M s_stream = randi([0 M(k)-1],1,n_sym); % Tao dong bieu tuong do dai n_sym s_mod = qammod(s_stream,M(k),'GRAY'); % Dieu che M-QAM for r = 1:size(SNR_db,2) % Vong lap tinh BER s_mod_awgn = awgn(s_mod,SNR_db(r),'measured'); % Tin hieu qua nhieu s_demod = qamdemod(s_mod_awgn,M(k),'GRAY'); % Giai dieu che M-QAM [num, ratio] = biterr(s_stream,s_demod); % Tinh ti le loi bit BER(k,r) = ratio; % Luu ti le loi bit vao BER end end semilogy(SNR_db,BER(1,:),'gx', 'LineStyle', 'none'); % Ve do thi BER voi M = 16 hold on; semilogy(SNR_db,BER(2,:),'ro', 'LineStyle', 'none'); % Ve do thi BER voi M = 64 semilogy(SNR_db,BER(3,:),'b*', 'LineStyle', 'none'); % Ve do thi BER voi M = 256 grid on; BER_lt = zeros(length(M),length(SNR_db)); for i = 1:length(M) BER_lt(i,:) = berawgn(SNR_db - 10*log10(log2(M(i))),'qam',M(i)); end semilogy(SNR_db,BER_lt(1,:),'g-'); % Ve do thi BER ly thuyet voi M = 16 semilogy(SNR_db,BER_lt(2,:),'r-'); % Ve do thi BER ly thuyet voi M = 64 semilogy(SNR_db,BER_lt(3,:),'b-'); % Ve do thi BER ly thuyet voi M = 256 title('Do thi ty le loi bit mo phong va ly thuyet cua ky thuat M-QAM'); xlabel('SNR_d_B');
  • 17. 16 ylabel('BER/Pe'); legend('BER 16-QAM','BER 64-QAM','BER 256-QAM','Pe 16-QAM','Pe 64-QAM','Pe 256-QAM', 'Location', 'southwest'); hold off;