AWGN通道输出实数而不是复数

时间:2017-05-31 22:25:19

标签: matlab

我在Matlab中运行代码时遇到此错误。但我可以在链接https://www.mathworks.com/help/comm/ref/comm.rsencoder-class.html上运行示例“通过AWGN信道传输缩短的RS编码的256-QAM调制符号流”,没有任何问题。

当我在代码中检查变量chnData中的值时,我看到实数。当我在示例代码中检查变量chan中的值时,我看到复数。我的代码出了什么问题?

PS:我正在研究R2012b,而Communication Toolbox版本是5.3。

错误讯息:

Error using comm.RectangularQAMDemodulator/step
Complexity mismatch with input 1; expected complex, got real.
Error in project (line 41)
            demData = step(qamDemodulator, chnData);

我的代码:

close all;
clear all;
clc;
enableRS = 1;
M = 16; % M-QAM
N = 15; % Reed-Solomon Coding : codelength
K = 11; % Reed-Solomon Coding : wordlength
EbNo = [-5:5]; % AWGN Channel : bit-to-noise energy
bps = log2(M); % AWGN Channel : bits per symbol
rsEncoder = comm.RSEncoder('CodewordLength', N, ...
                           'MessageLength',  K);
rsDecoder = comm.RSDecoder('CodewordLength', N, ...
                           'MessageLength',  K);
qamModulator = comm.RectangularQAMModulator('ModulationOrder', M, ...
                                            'NormalizationMethod', 'Average power');
qamDemodulator = comm.RectangularQAMDemodulator('ModulationOrder', M, ...
                                                'NormalizationMethod', 'Average power');
awgnChannel = comm.AWGNChannel('EbNo', EbNo, ...
                               'BitsPerSymbol', bps);
errorRate = comm.ErrorRate;
[H W] = size(EbNo);
errors = zeros(1,W);
for e = 1:W
    error = zeros(1,3);
    awgnChannel.EbNo = EbNo(e);
    if enableRS == 1
        while error(2) < 100 && error(3) < 1e7
             txData = randi([0 1], K, bps);
            encData = step(rsEncoder, bi2de(txData));
            modData = step(qamModulator, encData);
            chnData = step(awgnChannel, encData);
            demData = step(qamDemodulator, chnData);
            decData = step(rsDecoder, de2bi(demData));
             rxData = decData;
               error = step(errorRate, bi2de(txData), bi2de(rxData));
        end
    end
    errors(e) = error(1);
end
if enableRS == 1
    semilogy(EbNo, errors);
    grid;
    xlabel('Eb/No (db)');
    ylabel('Bit Error Rate');
    hold;
    uncoded = berawgn(EbNo, 'qam', M);
    semilogy(EbNo, uncoded);
end

1 个答案:

答案 0 :(得分:0)

发现错误!它现在已修好。

modData = step(qamModulator, encData);
chnData = step(awgnChannel, encData); // Should have been modData