16-QAM调制和解调 - 图中缺少一行

时间:2013-04-28 23:35:31

标签: matlab signal-processing wireless

我正在尝试对16-QAM进行调制和解调,然后尝试比较理论和模拟BER。

获取simulation - 图表中的行。 Missing the <simulation>-line

我无法理解我的代码有什么问题。有人能帮助我吗?

这是代码:

M=16;
SNR_db = [0 2 4 6 8 10 12];
x = randi([0,M-1],1000,1);
hmod = modem.qammod(16);
hdemod = modem.qamdemod(hmod,'SymbolOrder', 'Gray');
tx = zeros(1,1000);
for n=1:1000
tx(n) = modulate(hmod, x(n));
end
rx = zeros(1,1000);
rx_demod = zeros(1,1000);
for j = 1:7
    err = zeros(1,7);
    err_t = zeros(1,7);
    for n = 1:1000
rx(n) = awgn(tx(n), SNR_db(j));
rx_demod(n) = demodulate(hdemod, rx(n));

if(rx_demod(n)~=x(n))
    err(j) = err(j)+1;
end
    end
   % err_t = err_t + err;
end
theoryBer = 3/2*erfc(sqrt(0.1*(10.^(SNR_db/10))));
figure
semilogy(SNR_db,theoryBer,'-',SNR_db, err, '^-');
grid on
legend('theory', 'simulation');
xlabel('Es/No, dB')
ylabel('Symbol Error Rate')
title('Symbol error probability curve for 16-QAM modulation') 

2 个答案:

答案 0 :(得分:0)

http://www.dsplog.com/db-install/wp-content/uploads/2008/06/script_16qam_gray_mapping_bit_error_rate.m

这可以手动执行,而不需要任何工具箱功能(即花哨的调制器和解调器)。

你也可以尝试

  

编辑commdoc_mod

制作该文件的副本,你应该能够通过一个简单的循环让它做你想做的事。

修改

以下是对该文件的修改,它们为您提供模拟的EbNo曲线而不是符号错误率曲线。应该足够好用于任何实际目的。

M = 16;                     % Size of signal constellation
k = log2(M);                % Number of bits per symbol
n = 3e4;                    % Number of bits to process
nSyms = n/k;                % Number of symbols

hMod = modem.qammod(M);         % Create a 16-QAM modulator
hMod.InputType = 'Bit';         % Accept bits as inputs
hMod.SymbolOrder = 'Gray';         % Accept bits as inputs
hDemod = modem.qamdemod(hMod);  % Create a 16-QAM based on the modulator

x = randi([0 1],n,1); % Random binary data stream
tx = modulate(hMod,x);

EbNo = 0:10; % In dB
SNR = EbNo + 10*log10(k);

rx = zeros(nSyms,length(SNR));
bit_error_rate = zeros(length(SNR),1);
for i=1:length(SNR)
    rx(:,i) = awgn(tx,SNR(i),'measured');
end
rx_demod = demodulate(hDemod,rx);
for i=1:length(SNR)
    [~,bit_error_rate(i)] = biterr(x,rx_demod(:,i));
end

theoryBer = 3/(2*k)*erfc(sqrt(0.1*k*(10.^(EbNo/10))));
figure;
semilogy(EbNo,theoryBer,'-',EbNo, bit_error_rate, '^-');
grid on;
legend('theory', 'simulation');
xlabel('Eb/No, dB');
ylabel('Bit Error Rate');
title('Bit error probability curve for 16-QAM modulation');

答案 1 :(得分:0)

在您的代码中,您混淆了Symbol Error Probability和Bit Error Probability。此外err = zeros(1,7);是错误的。

更正后:

M=16;
SNR_db = 0:2:12;
N=1000;
x = randi([0,M-1],N,1);
k = log2(M); % bits per symbol

tx = qammod(x, M,'Gray');
err = zeros(1,7);
for j = 1:numel(SNR_db)
    rx = awgn(tx, SNR_db(j),'measured');
    rx_demod = qamdemod( rx, M, 'Gray' );
    [~,err(j)] = biterr(x,rx_demod);
end

theorySER = 3/2*erfc(sqrt(0.1*(10.^(SNR_db/10))));

figure
semilogy(SNR_db,theorySER,'-',SNR_db, err*k, '^-');
grid on
legend('theory', 'simulation');
xlabel('Es/No, dB')
ylabel('Symbol Error Rate')
title('Symbol Error Probability curve for 16-QAM modulation')

结果图是: enter image description here