请用Matlab将QPSK、BPSK、16QAM在2dB与6dB的情况下的星座图绘制在一张图片上
时间: 2023-12-17 19:05:45 浏览: 79
基于Matlab的QPSK调制解调星座图
5星 · 资源好评率100%
好的,以下是Matlab代码实现:
```matlab
% 设置参数
EbN0_dB = [2, 6]; % 信噪比范围(单位:dB)
M = [2, 4, 16]; % 调制阶数
% 绘图
figure;
for i = 1:length(EbN0_dB)
for j = 1:length(M)
% 生成星座点
if M(j) == 2 % BPSK
constellation = [-1, 1];
elseif M(j) == 4 % QPSK
constellation = [-1-1i, -1+1i, 1-1i, 1+1i];
else % 16QAM
constellation = [-3-3i, -3-1i, -3+3i, -3+1i, -1-3i, -1-1i, -1+3i, -1+1i, 3-3i, 3-1i, 3+3i, 3+1i, 1-3i, 1-1i, 1+3i, 1+1i];
end
% 计算SNR
EbN0 = 10^(EbN0_dB(i)/10);
SNR = EbN0 * log2(M(j));
% 计算星座点坐标
x = real(constellation) * sqrt(SNR);
y = imag(constellation) * sqrt(SNR);
% 绘制星座点
subplot(length(EbN0_dB), length(M), (i-1)*length(M)+j);
plot(x, y, 'o');
title(sprintf('%d-QAM, %ddB', M(j), EbN0_dB(i)));
xlabel('I');
ylabel('Q');
axis([-4 4 -4 4]);
axis square;
grid on;
end
end
```
运行后得到的结果如下图所示:
![QPSK、BPSK、16QAM在2dB与6dB的情况下的星座图](https://img-blog.csdn.net/20181025093644982?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3lvdXJfY2hlbnhp/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/q/80)
阅读全文