-
Notifications
You must be signed in to change notification settings - Fork 20
/
QPSK_Mod_Test.m
85 lines (72 loc) · 1.37 KB
/
QPSK_Mod_Test.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
%%
% Demo QPSK modulation
clear all; close all; clc
inStr = 'Hello';
decStr = double(inStr);
binDat = Binary_cnvrt(decStr);
% Map 0 bits to -1
for j = 1:length(binDat)
if binDat(j) == 0
binDat(j) = -1;
end
end
sym_data = QPSK_bin2symb(binDat);
fs = 1000;
fc = 10;
N = 128; % symbol length
t_end = 2; % symbol period in seconds
t = 0:1/fs:t_end-1/fs;
k = 0:N-1;
% QPSK modulated data stream
Q_data = zeros(1,N*length(sym_data));
for j = 0:length(sym_data)-1
Q_data(N*j+1:N*j+N) = exp(1i*(2*pi*fc.*k/fs+angle(sym_data(j+1))));
end
plot(t,real(Q_data))
% I = cos(2*pi*fc.*k/fs);
% Q = sin(2*pi*fc.*k/fs);
% s10 = 1-1i;
% c10 = exp(1i*(2*pi*fc.*t+angle(s10)));%*exp(angle(s10));
% figure(3)
% subplot(211)
% plot(k,I+Q)
% title('phase shift of -\pi/4')
% subplot(212)
% plot(k,c10)
%%
% f = -fs/2:1/t(end):fs/2;
% Xf = fftshift(fft(c10));
% Xm = real(Xf);
% Xa = angle(Xf);
% figure(5)
% stem(f,Xm)
% title('Magnitude')
% %%
% cc10 = ifft(Xf);
% figure(6)
% plot(t,real(cc10))
%%
% figure(1)
% subplot(211)
% plot(t,I)
% title('I component')
% subplot(212)
% plot(t,Q)
% title('Q component')
% symDat = zeros(1,length(binDat)*length(t)/2);
% for i = 1:2:length(binDat)
%
% end
% figure(2)
% subplot(221)
% plot(t,Q-I)
% title('01')
% subplot(222)
% plot(t,I+Q)
% title('11')
% subplot(223)
% plot(t,-I-Q)
% title('00')
% subplot(224)
% plot(t,I-Q)
% title('10')