Tài liệu Bài tập môn học: Kỹ Thuật truyền dẫn - Pdf 91


- 1 -
Bài tập môn học: Kỹ Thuật truyền dẫn
Bài I: Biểu diễn tớn hiệu của một số mó đường dõy và vẽ phổ
của chỳng.
I.1. Mó nguồn chương trỡnh Matlab: 1.Mó NRZ: file nrz_l.mfunction y=nrz_l(x)
for i=1:length(x)
if x(i)==0
temp(i) = -1;
else
temp(i) = +1;
end;
end
y=temp;

2.Mó CMI: file cmi_1.m

function y = cmi(x);
polar = +1; %chon cuc tinh cua bit 1 dau tien la duong

b=b+1;
i=i+1;
else

if (i<=length(x)-3)&(x(i+1)==0) & (x(i+2)==0) & (x(i+3)==0)
%truong hop 4 bit 0 lien tiep
if mod(b,2)==1
temp(i) = 0; %bit 0
temp(i+1) = 0; %bit 0
temp(i+2) = 0; %bit 0
temp(i+3) = -next_polar;%bit V
next_polar = -next_polar;
b=0;
i=i+4;
else
temp(i) = next_polar; %bit B
temp(i+1) = 0; %bit 0
temp(i+2) = 0; %bit 0
temp(i+3) = next_polar; %bit V
next_polar = -next_polar;
b=0;
i=i+4;
end
else
temp(i)=0; %truong hop 3 bit ke tiep khac 000
i=i+1;
end

end


temp(2*i-1) = -1;
temp(2*i) = +1;
end
end
y=temp;

6. Mó Polar RZ: File polar_RZ

function y = polar_RZ(x)
for i=1:length(x)
if x(i)==1
temp(2*i-1) = 1;
temp(2*i) = 0;
else
temp(2*i-1) = -1;
temp(2*i) = 0;
end;

- 4 -
end
y=temp;

7. Mó Unipolar RZ: File unipolar_RZ.m

function y=unipolar_RZ(x)

for i=1:length(x)

disp('10: RZ');
disp('20: ma polar_RZ');

- 5 -
disp('30: ma Manchester');
disp('40: ma CMI'); linecode = input('chon dang ma se phan tich: ');
switch linecode
%%Truong hop cac ma don bit day du
case {1}
data3 = data2;
TenDoThi='NRZ';
case {2}
data3 = hdb3(data2);
TenDoThi='HDB3';
case {3}
data3=ami(data2);
TenDoThi='AMI';
case {4}
data3=nrz_l(data2);
TenDoThi='NRZ-L';
%Truong hop cac ma co ve khong hay nua bit

case {10}
data3=RZ(data2);

subplot(3, 1, 1);
stairs(t,data2)
ylabel('Bien do');
title(TenDoThi);
axis([0 bits+1 -1.2 1.2]);
grid off;

%Do thi thoi gian cua du lieu da ma hoa
subplot(3, 1, 2);
stairs(t,data3);
ylabel(['Bien do']);
axis([0 bits+1 -1.2 1.2]);
grid off;
%Enconding using NRZ-L%

%Mo rong khong gian lay mau%
sampleRate = 2;
if mod(linecode,10)==0
Y1 = reshape(ones(sampleRate, 1)*data3, 1, sampleRate*bits*2);
else
Y1 = reshape(ones(sampleRate, 1)*data3, 1, sampleRate*bits);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%tinh FFT va ve do thi pho cong suat%
N=sampleRate*bits;
if mod(linecode,10) == 0
FFT_Y1 = abs(fft(Y1, N*2))/N/2;
FFT_Y1 = fftshift(FFT_Y1);
subplot(3, 1, 3);


Nhờ tải bản gốc
Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status