Matlab论坛
直播中

梦醒没你

9年用户 165经验值
擅长:电源/新能源 嵌入式技术 连接器 光电显示 存储技术 接口/总线/驱动
私信 关注
[经验]

用MATLAB函数绘制散点图和眼图

这个示例展示了如何使用通信系统工具箱,通过使用眼图和散点图来可视化信号行为。该示例使用QPSK信号,该信号通过方根升余弦(RRC)过滤器传递。
Scatter Plot
Set the RRC filter, modulation scheme, and plotting parameters.
span = 10;          % Filter span

rolloff = 0.2;      % Rolloff factor

sps = 8;            % Samples per symbol

M = 4;              % Modulation alphabet size

k = log2(M);        % Bits/symbol

phOffset = pi/4;    % Phase offset (radians)

n = 1;              % Plot every nth value of the signal

offset = 0;         % Plot every nth value of the signal, starting from offset+1



Create the filter coefficients using the rcosdesign function.
filtCoeff = rcosdesign(rolloff,span,sps);



Generate random symbols for an alphabet size of M.
rng default

data = randi([0 M-1],5000,1);



Apply QPSK modulation.
dataMod = pskmod(data,M,phOffset);



Filter the modulated data.
txSig = upfirdn(dataMod,filtCoeff,sps);



Calculate the SNR for an oversampled QPSK signal.
EbNo = 20;

snr = EbNo + 10*log10(k) - 10*log10(sps);



Add AWGN to the transmitted signal.
rxSig = awgn(txSig,snr,'measured');



Apply the RRC receive filter.
rxSigFilt = upfirdn(rxSig, filtCoeff,1,sps);



Demodulate the filtered signal.
dataOut = pskdemod(rxSigFilt,M,phOffset,'gray');



Use the scatterplot function to show scatter plots of the signal before and after filtering. You can see that the receive filter improves performance as the constellation more closely matches the ideal values. The first span symbols and the last span symbols represent the cumulative delay of the two filtering operations and are removed from the two filtered signals before generating the scatter plots.
h = scatterplot(sqrt(sps)*txSig(sps*span+1:end-sps*span),sps,offset,'g.');

hold on

scatterplot(rxSigFilt(span+1:end-span),n,offset,'kx',h)

scatterplot(dataMod,n,offset,'r*',h)

legend('Transmit Signal','Received Signal','Ideal','location','best')







Eye Diagram
Display 1000 points of the transmitted signal eye diagram over two symbol periods.
eyediagram(txSig(sps*span+1:sps*span+1000),2*sps)







Display 1000 points of the received signal eye diagram.
eyediagram(rxSig(sps*span+1:sps*span+1000),2*sps)






Observe that the received eye diagram begins to close due to the presence of AWGN. Moreover, the filter has finite length which also contributes to the non-ideal behavior.



回帖(1)

CHNlyt

2018-8-8 20:34:53
赞。
举报

更多回帖

发帖
×
20
完善资料,
赚取积分