文章目录
前言
本文完成以下内容:
(1)建立一个QPSK传输系统,并引入EsNo=20dB(SNR=0dB)的噪声,接收端对带噪信号进行匹配滤波。
(2)分别画出成形滤波器输出信号的实部波形和匹配滤波器输出信号的实部波形。
(3)分别画出成形滤波器输出信号的2D彩色眼图,和匹配滤波器输出信号的2D彩色眼图,2D彩色眼图中,颜色强度与给定时间输入信号幅度的概率密度函数(PDF)成比例。
一、MATLAB仿真代码
代码如下:
clc
clear all
close all
%% Create a QPSK transmission system
% Initialize system parameters
Fs = 10000;
Rs = 100;
nSamps = Fs/Rs;
rollOff = 0.5;
M = 4;
% comm.QPSKModulator System object
hMod = comm.QPSKModulator;
% Square root raised cosine filters
filtSpec = fdesign.pulseshaping(nSamps,'Square root raised cosine',...
'Nsym,Beta',6,rollOff);
hTxFlt = design(filtSpec); hTxFlt.PersistentMemory = true;
hRxFlt = copy(hTxFlt); hTxFlt.Numerator = hTxFlt.Numerator*nSamps;
% Generate modulated and pulse shaped signal
msgLen = 1000;
msgData = randi([0 M-1],msgLen,1);
msgSymbols = step(hMod, msgData);
msgTx = hTxFlt.filter(upsample(msgSymbols, nSamps));
% Create an comm.AWGNChannel System object
EsNo = 20;
SNR = EsNo - 10*log10(nSamps);
hChan = comm.AWGNChannel('NoiseMethod', 'Signal to noise ratio (SNR)',...
'SNR', SNR);
hChan.SignalPower = (msgTx' * msgTx)/ length(msgTx);
% Modulated signal through AWGN channel
msgRx = step(hChan, msgTx);
% Matched filtering
msgRxMf = hRxFlt.filter(msgRx);
%% Plot the Tx filtered in-phase signal and the Nf filtered in-phase signal
t = 0:1/Fs:50/Rs-1/Fs;
idx = round(t*Fs+1);
figure();
subplot(211)
plot(t, real(msgTx(idx)));
title('Modulated, filtered in-phase signal');
xlabel('Time (sec)');
ylabel('Amplitude');
grid on;
subplot(212)
plot(t, real(msgRxMf(idx)));
title(['Modulated, filtered noisy in-phase signal, Es/No = ' ...
num2str(EsNo) ' dB']);
xlabel('Time (sec)');
ylabel('Amplitude');
grid on;
%% eye diagram
% Create an eye diagram object
eyeObj = commscope.eyediagram(...
'SamplingFrequency', Fs, ...
'SamplesPerSymbol', nSamps, ...
'SymbolsPerTrace', 2, ...
'MinimumAmplitude', -1.5, ...
'MaximumAmplitude', 1.5, ...
'OperationMode', 'Complex Signal', ...
'PlotType', '2D Color', ...
'PlotTimeOffset', 0);
eyeObjN = copy(eyeObj);
% Update the first eye diagram object with the transmitted signal
eyeObj.update(msgTx);
% Update the second eye diagram object with the received signal
eyeObjN.update(msgRxMf);
二、仿真结果
代码运行结果画图如下: