|
Raqamli aloqa 3-9-Amaliy ishlar
|
bet | 4/6 | Sana | 28.12.2023 | Hajmi | 2,71 Mb. | | #128837 |
Bog'liq Ozodbek raqamli 3-9 amaliy to\'liq ish#7 Digital communication
Simulation of Phase Shift Keying
(BPSK- binary phase-shift keying,2-PSK)
Matlab code:
clear all
char = bin2dec('01111101') % ni decimal (desimal) qiymatga o'tkazvoldim
Ac=1; % Ac ni 1 ga tenglab oldim
As=Ac %ikkalasini tenglab oldim
fc=2.15; % fc ni 2.15 ga tenglashtirvoldim
first_data=0
a(1:2)=first_data; % a va t1 massivlarini birinchi ikki elementini first_data ga tenglab qoydim
t1(1:2)=[0,1];
i=3;
for n=0:7
bit_n=bitshift(char,-n); % Binar qiymatdagi bitni n martaga o'ngga surish
a(i:i+1) = bitand(bit_n,1);
t1(i:i+1) = [n+1,n+2];
i=i+2;
end
for j=1:4499
t2(j)=j/500;
i=floor(t2(j)*2+1);
c(j)=Ac*cos(2*pi*fc*t2(j));
s(j)=As*cos(2*pi*fc*t2(j)+a(i)*pi); % s(j) o'zgaruvchisiga As * cos(2*pi*fc*t2(j) + a(i)*pi) qiymati olinadi.
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)=[0,1];
rec_c=3;
for j=3:length(s)
if t2(j)>time_c-0.2
if abs(s(j-1)-s(j))>Ac*0.1
change_point=t2(j-1)
buff_data=~last_data;
elseif abs(s(j-1))s(j) || s(j-2)>s(j-1) && s(j-1)change_point=t2(j-1) % change_point o'zgaruvchisiga t2 massivi j-1 indeksdagi qiymati olinadi.
buff_data=~last_data;
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 massivi 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)
|
| |