基本原理
参考书籍:樊昌信老师的《通信原理》第七版
源代码
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 16QAM 调制与解调
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc;
close all;
clear all;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 参数设置
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
M =16; % 16进制
k = log2(M);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 信源
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
count=1e4;
x = randi([0 M-1],1,count);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 调制
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
y = qammod(x,M);
scatterplot(y);
title('接收信号星座图');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 信道(加入高斯白噪声)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SNR=20; % 信噪比
y_noise = awgn(y,SNR); % 加入高斯白噪声
scatterplot(y_noise);
title('接收信号星座图(SNR=20)');
SNR=-20; % 信噪比
y_noise1 = awgn(y,SNR); % 加入高斯白噪声
scatterplot(y_noise1);
title('接收信号星座图(SNR=-20)');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 解调
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
y1=qamdemod(y_noise,M); % 解调
scatterplot(y1);
title('解调信号星座图(SNR=-20)');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 误码率计算
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
sum_error=0;
for n=1:count
if y1(n)~=x(n)
sum_error=sum_error+1;
end
end
mean_error=sum_error/count;
fprintf('误码数为%g\n',sum_error);
fprintf('误码率为%g\n',mean_error);
仿真结果