调制
sps = 8;
RolloffFactor = 0.2;
FilterSpanInSymbols = 10;bits = randi([0, 1], 224*8, 1); % 1792symbols = bits*2 - 1; % 1792
re = -symbols(2:2:end); % 896
im = -symbols(1:2:end); % 896pFilterTx = comm.RaisedCosineTransmitFilter(...'Shape', 'Square root', ...'RolloffFactor', RolloffFactor, ...'FilterSpanInSymbols', FilterSpanInSymbols, ...'OutputSamplesPerSymbol', sps, ...'Gain', sqrt(sps/2));filtered = pFilterTx([re im]);% 896 * sps = 3584
filteredRe = filtered(:, 1);
filteredIm = filtered(:, 2);% oqpskWaveform = complex(filteredRe, filteredIm);
% oqpskWaveform = complex(filteredRe, filteredAligned);
oqpskWaveform = complex(...[filteredRe ; zeros(sps/2, 1)], ...[zeros(sps/2, 1) ; filteredIm]); % 3586 * 2
查看TX的中间状态
% 绘制相位图
plot(unwrap(angle(oqpskWaveform)),'o-')
% 绘制IQ图
plot(1:length(oqpskWaveform),real(oqpskWaveform),1:length(oqpskWaveform),imag(oqpskWaveform))
% 频谱图
plot(abs(fftshift(fft(oqpskWaveform))))
% 星座图
scatterplot(oqpskWaveform);
信道
snr = 7;
rxWaveform = awgn(oqpskWaveform,snr);
解调
pFilterRx = comm.RaisedCosineReceiveFilter(...'Shape', 'Square root', ...'RolloffFactor', RolloffFactor, ...'FilterSpanInSymbols', FilterSpanInSymbols, ...'InputSamplesPerSymbol', sps, ...'DecimationFactor', sps, ...'DecimationOffset', sps/2, ...'Gain', sqrt(sps/2));alignedRx = complex(...[zeros(sps/2, 1); real(rxWaveform)], ...[imag(rxWaveform);zeros(sps/2, 1)]); % 3588 * 2 filteredRx = pFilterRx(alignedRx); % 3588/4 = 897demodulatedRx = qamdemod(filteredRx, 4, [1 3 0 2]); % 897
outputBits = int2bit(demodulatedRx, 2); % 1792
BER
delay = 2 * FilterSpanInSymbols; % 20
[~, ber] = biterr(bits(1:end-delay), outputBits(delay+1:end-2))