有的时候信号加了相位噪声之后星座点会旋转,所以给星座点加颜色,可以看得更清。
上图
clear
close all
M = 16; % Modulation order (alphabet size or number of points in signal constellation)
k = log2(M); % Number of bits per symbol
n = 30000; % Number of bits to process
sps = 1; % Number of samples per symbol (oversampling factor)
rng default;
dataIn = randi([0 1],n,1); % Generate vector of binary data
dataInMatrix = reshape(dataIn,length(dataIn)/k,k);
dataSymbolsIn = bi2de(dataInMatrix);
dataMod = qammod(dataSymbolsIn,M); % Gray coding with phase offset of zero
EbNo = 10;
snr = EbNo+10*log10(k)-10*log10(sps);
receivedSignal = awgn(dataMod,snr,'measured');
receivedSignal=receivedSignal.*exp(1j*pi*0.2);
colour=linspace(1,10,16);
C=colour(dataSymbolsIn+1);
figure
scatter(real(receivedSignal),imag(receivedSignal),2,C)
title('received symbol')
print(gcf,'-dpng','-r300','received symbol.png')
figure
scatter(real(dataMod),imag(dataMod),180,C,'filled')
title('transmitted symbol')
print(gcf,'-dpng','-r300','transmitted symbol.png')
python
因为python里面没有调制的函数,如果不调库的话,所以就画PAM信号的,主要用的是c和cmap
import numpy as np
import matplotlib.pyplot as plt
from math import pi
k=2
M=2**k
symLen=2**13
np.random.seed(2)
txSymbols = np.random.randint(0,4,size=symLen)
#plt.scatter(txSymbols.real,txSymbols.imag,c=txSymbols,cmap=plt.cm.Set1)
rxSymbols=txSymbols*np.exp(1j*pi*0.15)
plt.scatter(rxSymbols.real,rxSymbols.imag,c=txSymbols,cmap=plt.cm.Set1)