Bài tập môn học Kỹ thuật truyền dẫn
1
I. MÃ ĐƯỜNG DÂY
Các hàm được viết và lưu trong các m-file riêng với tên trùng
tên hàm. x là tọa độ mà các đoạn thẳng được vẽ tại vị trí đó
1.Các hàm bổ trợ
Các hàm vẽ các đoạn nằm dọc
function doc1(x)%ve mot doan nam doc dai 1 don vi
u=linspace(0,1,1000);
plot(x,u,'r','LineWidth',5)
hold on;
grid on;
function doc_1(x))%ve mot doan nam doc dai -1 don vi
u=linspace(-1,0,1000);
plot(x,u,'r','LineWidth',5)
hold on;
grid on;
function doc2(x)%ve mot doan nam doc dai 2 don vi
u=linspace(-1,1,1000);
plot(x,u,'r','LineWidth',5)
hold on;
grid on; Các hàm vẽ các đoạn nằm ngang
function ngang1_5(x)%ve mot doan nam ngang
%cao tren truc hoanh dai 1/2 don vi
t=linspace(x,(2*x+1)/2,100);
for a=1:100
N(a)=1;
end
plot(t,N,'r','LineWidth',5)
hold on;grid on;
%ve mot doan nam phia duoi truc hoanh ngang dai 1 don vi
function ngang_0_1(x)
t=linspace(x,x+1,100);
for a=1:100
N(a)=-1;
end
plot(t,N,'r','LineWidth',5)
hold on;grid on;
function ngang1_1(x)%ve mot doan nam ngang dai 1 don vi
t=linspace(x,x+1,100);
for a=1:100
N(a)=1;
end
plot(t,N,'r','LineWidth',5)
hold on;
3
t=1;
end
%ve ma nguoc 0000->B00V
function t=HDB3_nguoc(x,t)
if t==1%neu truoc do la mot xung duong
am(x-1)%ve mot xung am
t=0;
else
duong(x-1)%ve mot xung duong
t=1;
end
ngang0_1(x)%00
ngang0_1(x+1)%00
%V la bit pha' luat
if t==1%neu truoc do la mot xung duong
duong(x+2)
t=1;
else
am(x+2)
t=0;
end
1. Đoạn mã vẽ các mã đường truyền
%ma AMI
function AMI(x)
n=length(x);
end
if (x(i)==1)&(x(i+1)==0)
doc1((2*(i-1)+1)/2)
end
if (x(i)==0)&(x(i+1)==1)
doc1(i)
end
end
%suon cuoi cung
xlabel('RZ don cuc')
% ma RZ luong cuc
function POLAR_RZ(x)
n=length(x);
for i=1:n
if x(i)==1
duong(i-1)
else
am(i-1)
end
end
xlabel('RZ luong cuc')
%ve ma NRZ don cuc
function NRZ(x)
n=length(x);
for i=1:n
if i==n
x(i+1)=x(i);
if x(i)==1
ngang1_1(i-1)
else
ngang_0_1(i-1)
end
if ((x(i)==1)&(x(i+1)==0))|((x(i)==0)&(x(i+1)==1))
doc2(i)
end
end
%suon dau tien
if x(1)==1
doc1(0)
else
doc_1(0)
end
%suon cuoi cung
if x(n)==1
doc1(n)
else
doc_1(n)
end
xlabel('NRZ_L')
%ma HDB3
function HDB3(x)
n=length(x);
truth=0;%bien kiem tra xung duong=0 hay am=1
tn=0;%bien kiem tra=0 HDB3_thuan hoac=1 HBD3_nguoc
i=1;
while i<=n
end
i=i+dem;
end
xlabel('HBD3')
% Manchester
function Manchester(x)
n=length(x);
for i=1:n
if i==n
x(i+1)=x(i);
end
if x(i)==1
ngang1_5(i-1)
doc2(i-1/2)
ngang_0_5(i-1/2)
else
ngang_0_5(i-1)
doc2(i-1/2)
ngang1_5(i-1/2)
end
end
%ve cac suon xung
for i=1:n-1
if x(i)==x(i+1)
doc2(i)
end
end
%suon xung cuoi cung
if x(n)==1
else
if x(i+1)==0
if t==1
am(i-1)
am(i)
t=0;%bit V trai luat
else
duong(i-1)
duong(i)
t=1;%bit V trai luat
end
dem=2;
else
ngang0_1(i-1)
end
end
i=i+dem;
end
xlabel('B2ZS')
% ma CMI
function CMI(x)
n=length(x);
truth=0;
for i=1:n
if i==n
x(i+1)=x(i);
end
if x(i)==1
if truth==0
end
if (x(n)==1)&(truth==1)
doc1(n)
end
if x(n)==0
doc1(n)
end
xlabel ('CMI')
Giả sử ta có tín hiệu đầu vào là
x= [1,1,1,0,0,0,0,0,1,0,1,1,0,1];
• Dạng tín hiệu đối với từng mã đường dây là
1 . Tín hiệu Unipolar NRZ
Bài tập môn học Kỹ thuật truyền dẫn
9 Bài tập môn học Kỹ thuật truyền dẫn
11
4. Tín hiệu AMI-NRZ(Bipolar NRZ)
5. Tín hiệu HDB3
Bài tập môn học Kỹ thuật truyền dẫn
126. Tín hiệu Manchester
Bài tập môn học Kỹ thuật truyền dẫn
13
.
Phổ của mã Polar NRZ
Bài tập môn học Kỹ thuật truyền dẫn
15
Phổ của mã Manchester
Bài tập môn học Kỹ thuật truyền dẫn
17
Bài tập môn học Kỹ thuật truyền dẫn
18
• Vẽ đồ thị mật độ xác suất
•
Vẽ đồ thị quan hệ giữa
No
E
B
và P
E
Bài tập môn học Kỹ thuật truyền dẫn
20
ans =
A(ASK) = 0.04753
ans =
Cong suat cua tin hieu ASK la :0.00113
ans =
A(FSK) = 0.03006
ans =
Cong suat cua tin hieu FSK la :0.00045
Bài tập môn học Kỹ thuật truyền dẫn
21
plot(u,N,'b')
hold on;
end
end
grid on;
xlabel('ASK')
2. BPSK
%BPSK Binary phase shitf keying
function BPSK(x)
n=length(x);
for i=1:n
if x(i)==1
wave(i-1,pi,1,1,1)%ve tin hieu hinh sin lech pha PI
else
wave(i-1,0,1,1,1)
end
end
xlabel('BPSK')
Bài tập môn học Kỹ thuật truyền dẫn
22
3. QPSK
%QPSK Quadrature phase shitf keying
function BPSK(x)
n=length(x);
i=1;
if mod(n,2)==1
n=n-1;
end
while i<=n-2
if (x(i)==0)&(x(i+1)==0)&(x(i+2)==0)%000
wave(i-1,0,1,3,1)
end
if (x(i)==0)&(x(i+1)==0)&(x(i+2)==1)%001
wave(i-1,pi/4,1,3,1)
end
if (x(i)==0)&(x(i+1)==1)&(x(i+2)==0)%010
wave(i-1,2*pi/4,1,3,1)
end
if (x(i)==0)&(x(i+1)==1)&(x(i+2)==1)%011
wave(i-1,3*pi/4,1,3,1)
end
if (x(i)==1)&(x(i+1)==0)&(x(i+2)==0)%100
Bài tập môn học Kỹ thuật truyền dẫn
23
wave(i-1,4*pi/4,1,3,1)
end
if (x(i)==1)&(x(i+1)==0)&(x(i+2)==1)%101
wave(i-1,5*pi/4,1,3,1)
end
if (x(i)==1)&(x(i+1)==1)&(x(i+2)==0)%110
wave(i-1,6*pi/4,1,3,1)
end
if (x(i)==1)&(x(i+1)==1)&(x(i+2)==1)%111
wave(i-1,7*pi/4,1,3,1)
end
i=i+3;
while i<=n-3
if (x(i)==0)&(x(i+1)==0)&(x(i+2)==0)&(x(i+3)==0)%0000
wave(i-1,pi/4,1,4,1)
end
if (x(i)==0)&(x(i+1)==0)&(x(i+2)==0)&(x(i+3)==1)%0001
wave(i-1,3*pi/4,1,4,0.7653)
end
if (x(i)==0)&(x(i+1)==0)&(x(i+2)==1)&(x(i+3)==0)%0010
wave(i-1,pi/8,1,4,0.7653)
end
if (x(i)==0)&(x(i+1)==0)&(x(i+2)==1)&(x(i+3)==1)%0011
Bài tập môn học Kỹ thuật truyền dẫn
24
wave(i-1,2*pi/8,1,4,0.5)
end
if (x(i)==0)&(x(i+1)==1)&(x(i+2)==0)&(x(i+3)==0)%0100
wave(i-1,6*pi/8,1,4,1)
end
if (x(i)==0)&(x(i+1)==1)&(x(i+2)==0)&(x(i+3)==1)%0101
wave(i-1,5*pi/8,1,4,0.7653)
end
if (x(i)==0)&(x(i+1)==1)&(x(i+2)==1)&(x(i+3)==0)%0110
wave(i-1,7*pi/8,1,4,0.7653)
end
if (x(i)==0)&(x(i+1)==0)&(x(i+2)==1)&(x(i+3)==1)%0111
wave(i-1,6*pi/8,1,4,0.5)
end
if (x(i)==1)&(x(i+1)==0)&(x(i+2)==0)&(x(i+3)==0)%1000
wave(i-1,14*pi/8,1,4,1)
1. Phổ của tín hiệu ASK
Bài tập môn học Kỹ thuật truyền dẫn
25 2. Phổ của tín hiệu FSK