Raqamli aloqa 3-9-Amaliy ishlar




Download 2,71 Mb.
bet3/6
Sana28.12.2023
Hajmi2,71 Mb.
#128837
1   2   3   4   5   6
Bog'liq
Ozodbek raqamli 3-9 amaliy to\'liq ish

#6 Digital communication
Simulation of Frequency Shift Keying

Matlab code:
clear all
char=double('Ozodbek') % charda o’zimni ismimni kiritvoldim.
Ac=1; % Ac ni ixtiyoriy ovoldim.
fcO=7; % fcO va fcZ larni o’zlashtirvoldim
fcZ=3;
i=1 % i ni birga tenglab qo’ydim
for cc=1:length(char) % Har bir belgini uchun
for n=0:7 % 0 dan 7 gacha bo'lgan n sonlari uchun
bit_n=bitshift(char(cc),-n); % Belgi uchun ASCII raqamini n martaga o'ngga surib olish
a(i) = bitand(bit_n,1); % Bitmaska orqali eng kam bitni olish va a massiviga saqlash
a(i+1)=a(i);> Massivdagi birinchi elementni keyingi elementga nusxalash
t1(i) = (cc-1)*8+n; %Belgi va n asosida t1 massivi indeksini hisoblash
t1(i+1) = t1(i)+1; % Indeksni 2 qilib oshirish va keyingi elementga nusxalash
i=i+2; end % Indeksni 2 qilib oshirish
end
for j=1:length(char)*4000-1
t2(j)=j/500;
i=floor(t2(j)*2+1);
cO(j)=Ac*sin(2*pi*fcO*t2(j));
cZ(j)=Ac*sin(2*pi*fcZ*t2(j));
if a(i)==0
s(j)=cZ(j);
else
s(j)=cO(j); end
end
subplot(5,1,1);
plot(t1,a);
subplot(5,1,2);
plot(t2,cO);
subplot(5,1,3);
plot(t2,cZ);
subplot(5,1,4);
plot(t2,s);
j=1;
for k=3:length(t2)
if s(k-2)s(k) % Agar s(k-2) qiymati s(k-1) dan kichik va s(k-1) qiymati s(k) dan katta bo'lsa, shart qanoatlantiriladi.
ext_p_t(j)=t2(k); j=j+1; end
end
Fmin=1000;
Fmax=-1000;
for i=1:length(ext_p_t)-1
freq=1/(ext_p_t(i+1)-ext_p_t(i)); % freq o'zgaruvchisiga ext_p_t massivi i+1 indeksidagi va i indeksidagi elementlar orasidagi chastota olinadi.
if freqFmin=freq;
end
if freq>Fmax
Fmax=freq;
end
freqs(i)=freq;
end
mid_freq=Fmax-Fmin;
time_c=1;
one_c=0;sample_c=0;
for k=1:length(freqs)
if ext_p_t(k+1)sample_c=sample_c+1;
if freqs(k)>mid_freq
one_c=one_c+1;
end
else t_data(time_c)=time_c
if one_c>sample_c/4
data(time_c)=1;
else
data(time_c)=0;end
time_c=time_c+1;
one_c=0;sample_c=0;
end;
end
k2=1;
for k=1:length(data) % data massivining har bir elementi uchun tsikl ochiladi.
p_d(k2)=data(k);
p_d(k2+1)=data(k);
p_t_d(k2)= t_data(k)-1;
p_t_d(k2+1)= t_data(k);
k2=k2+2
end
subplot(5,1,5);
plot(p_t_d,p_d);




Download 2,71 Mb.
1   2   3   4   5   6




Download 2,71 Mb.