hMod = comm.DQPSKModulator(pi/4, 'SymbolMapping', 'Binary');
hAWGN = comm.AWGNChannel('NoiseMethod', 'Signal to noise ratio (SNR)','SNR', 50);
hDemod = comm.DQPSKDemodulator(pi/4, 'SymbolMapping', 'Binary');
hError = comm.ErrorRate('ComputationDelay',1);
data = randi( [0 3], 10000, 1);
modSignal = step(hMod, data);
modSignal_my = zeros(length(data), 1);
Theta=pi/4;
for i=1:length(data)
if (i==1)
modSignal_my(i) = exp(1i * Theta + 1i * pi * data(i) / 2);
else
modSignal_my(i) = modSignal_my(i-1) * exp(1i * Theta + 1i * pi * data(i) / 2);
end
end
noisySignal = step(hAWGN, modSignal);
receivedData = step(hDemod, noisySignal);
receivedData_my = zeros( length(noisySignal), 1 );
for i=1:length(noisySignal)
if(i==1)
receivedData_my(i) = angle( noisySignal(i) ) - Theta;
else
receivedData_my(i) = angle( noisySignal(i) )-angle( noisySignal(i-1) );
end
end
receivedData_my = receivedData_my + 8 * pi;
receivedData_my = mod(receivedData_my, 2 * pi);
receivedData_my = floor( receivedData_my / (pi / 2) );