|
Raqamli aloqa 3-9-Amaliy ishlar
|
bet | 5/6 | Sana | 28.12.2023 | Hajmi | 2,71 Mb. | | #128837 |
Bog'liq Ozodbek raqamli 3-9 amaliy to\'liq ish#8 Digital communication
Simulation of Phase Shift Keying
(QPSK- quadrature phase-shift keying,4-PSK)
Matlab code:
clear all
clf
char=double('SEND')
Ac=1; %Ac ni kiritvoldim
As=Ac %As va Ac ni tenglashtirvoldim
fc=2.25; %fc ni kiritvoldim
first_data=0
a(1:2)=first_data; %first_dataga tenglashtirvoldim
t1(1:2)=[0,1];
i=3;
for cc=1:length(char)
for n=0:2:7
bit_n=bitshift(char(cc),-n); %o'zgaruvchisiga char(cc) qiymati o'ngga n martaga o'zgartirilgan bitlarini olish uchun ishlatiladi.
a(i:i+1) = bitand(bit_n,3);
t1(i) = (i-1)/2;
t1(i+1) = t1(i)+1;i=i+2;
end; end
for j=1:length(char)*20000+4999 % j o'zgaruvchisiga char massivining uzunligi ko'paytib 20000 ga qo'shilib, 4999 ga qo'shilib chiqilgan hammasi soni berilgan.
t2(j)=j/5000;
i=floor(t2(j)*2+1);
c(j)=Ac*sin(2*pi*fc*t2(j));
s(j)=Ac*sin(2*pi*fc*t2(j)+a(i)*pi/2+pi/4);
end
subplot(4,1,1);plot(t1,a);subplot(4,1,2);plot(t2,c);subplot(4,1,3);plot(t2,s,'.'); % 4 ta subplotdan iborat bo'lgan ko'rsatkich chizish uchun subplot funksiyasi ishlatilgan.
last_data=first_data;
buff_data=first_data
time_c=1;
rec_data(1:2)= first_data;
rec_time(1:2)= [first_data,1];
rec_c=3;
for j=4:length(s)
if t2(j)>time_c-0.2
if abs(s(j-1)-s(j-2))>Ac*0.1
change_point=t2(j-1)
buff_data=get_data(s(j-3:j),last_data); % buff_data o'zgaruvchisiga s massivi j-3 dan j gacha bo'lgan bo'lagi va oxirgi last_data qiymati asosida olinadi.
else
if abs(s(j-2))s(j)||s(j-3)>s(j-2)&&s(j-1)change_point=t2(j)
buff_data=get_data(s(j-3:j),last_data);
end; end; end
if t2(j)>time_c
last_data=buff_data
rec_data(rec_c:rec_c+1)=last_data;
rec_time(rec_c:rec_c+1)=[time_c,time_c+1];
time_c=time_c+1;
rec_c=rec_c+2;
end;end
subplot(4,1,4);plot(rec_time,rec_data)
function res = get_data(s,last_data) % get_data funksiyasi s massivining ma'lum bir bo'lagini va oxirgi last_data qiymatini olib, yangi ma'lumotlarni hosil qiladi. Chiquvchi qiymat sifatida qaytariladi.
degree2=asin(double(s(2)))/pi*180;
degree3=asin(double(s(3)))/pi*180;
if s(2)>s(1)
if degree2<0 degree2=360+degree2;end
else
if degree2>0 degree2=180-degree2;
else degree2=abs(180-degree2);end
end
if s(4)>s(3)
if degree3<0 degree3=360+degree3;end
else
if degree3>0 degree3=180-degree3; % Agar degree3 qiymati musbat (pozitiv) bo'lsa, uni 180 dan ayirib olish va natijani o'zgaruvchiga qaytaradi.
else degree3=abs(180-degree3);end
end
degree2=degree2-last_data*90;
degree3=mod(degree3-degree2,360);
res=round(degree3/90); end
0>0>
|
| |