Professional Documents
Culture Documents
8 9 Topshiriq
8 9 Topshiriq
OF UZBEKISTAN
TASHKENT UNIVERSITY OF INFORMATION TECHNOLOGIES
NAMED AFTER MUHAMMAD AL-KHWARIZMI
Assignment –
8,9
Tashkent – 2023
Practise 8
Theme: Simulation of Phase Shift Keying
(QPSK-quadrature phase-shift keying, 4-PSK)
Code:
clc
clear variables
clf
char = double('RAINY');
Ac = 1;
As = Ac;
fc = 2;
first_data = 1;
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:nIterations
t2(j) = j / 5000;
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 / 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) = [0,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);
else
if abs(s(j-2)) < Ac*0.95 && (s(j-3) < s(j-2) && (j-1) > s(j) || s(j-3)
> s(j-2) && s(j-1) < s(j))
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);
Result:
Practise 9
Theme: Simulation of Phase Shift Keying
(QPSK-quadrature phase-shift keying, 4-PSK)
Code:
clc
clear variables
clf
x = [0 1 0 0 0 0 1 0 0 1 1 0 1 1 1 1 0 1 1 0 0 0 1 0 0 1 1 1 0 1 0 1 0 1 1 1 0 0 1
0]; %Binary data is 'Bobur'
Ac = 1;
As = Ac;
fc = 1.35;
first_data = 1;
a(1:2)=first_data;
t1(1:2) = [0,1];
i = 3;
for cc = 1:length(x)
for n = 0:2:7
bit_n = bitshift(x(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:nIterations
t2(j) = j / 5000;
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 / 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);
else
if abs(s(j-2)) < Ac*0.95 && (s(j-3) < s(j-2) && (j-1) > s(j) || s(j-3)
> s(j-2) && s(j-1) < s(j))
change_point = t2(j);
buff_data = get_data(s(j-3:j), last_data);
end
end
end