|
Raqamli aloqa 3-9-Amaliy ishlar
|
bet | 6/6 | Sana | 28.12.2023 | Hajmi | 2,71 Mb. | | #128837 |
Bog'liq Ozodbek raqamli 3-9 amaliy to\'liq ish#9 Digital communication
Simulation of Quadrature amplitude modulation
Matlab code:
clear all
clf
char=double('TEST')
Ac=1;
As=Ac
fc=1.35;
first_data=1 % first_data o'zgaruvchisiga 1 qiymati o'zlashtiriladi.
a(1:2)=first_data;
t1(1:2)=[0,1];
i=3;
for cc=1:length(char)
for n=0:2:7
bit_n=bitshift(char(cc),-n);
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
t2(j)=j/5000;
i=floor(t2(j)*2+1);
c(j)=Ac*cos(2*pi*fc*t2(j)); %c(j) o'zgaruvchisiga j-indeksdagi qiymat Ac * cos(2*pi*fc*t2(j)) olinadi.
s(j)=Ac*cos(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,'.');
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 o'zlashtiriladi
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]; % rec_time massivining rec_c va rec_c+1 indekslari orasiga time_c va time_c+1 qiymatlari o'zlashtiriladi.
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)
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; % Agar degree2 manfiy bo'lsa, uni 360 ga qo'shib qaytaradi.
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;
else degree3=abs(180-degree3); %degree3 qiymatini 180 dan ayirib olish va natijani abs() funksiyasi orqali musbat (pozitiv) qiymatga o'zgartiradi.
end
end
degree2=degree2-last_data*90;
degree3=mod(degree3-degree2,360); % degree3 o'zgaruvchisiga (degree3 - degree2) ni 360 ga bo'lib bo'linishi natijasini o'zlashtiradi.
res=round(degree3/90); end
0>0>
|
| |