| 1 | function demodData = deqpskdemod(modData) |
| 2 | %% Input: Rx samples from a DE-QPSK constellation. |
| 3 | %% Output: Data as integers between 0 to 3 inclusive. |
| 4 | %% Parameter formats are the same as MATLAB's "pskdemod" function. |
| 5 | |
| 6 | %% MATLAB has no easy way to perform just the decision stage, |
| 7 | % so here we demodulate and then remodulate to get the closest symbols. |
| 8 | demod1 = pskdemod(modData, 4, 0, 'gray'); |
| 9 | remod = pskmod(demod1, 4, 0, 'gray'); |
| 10 | |
| 11 | clear demod1; % save some memory |
| 12 | |
| 13 | [~, wavelength_channels] = size(modData); |
| 14 | %% Instead of looping through the symbols, it will be faster |
| 15 | % to vectorize the operation. So we create an array that is |
| 16 | % delayed by 1 sample. |
| 17 | delayed = [ones(1, wavelength_channels); remod(1:end-1, :)]; |
| 18 | demodData = uint8(pskdemod(remod .* conj(delayed), 4, 0, 'gray')); |
| 19 | end |