当我在Matlab中运行我的代码时,我会得到这个错误。但我可以在链路https://www.mathworks.com/help/comm/ref/comm.rsencoder-class.html上运行“通过AWGN信道传输缩短的RS编码,256-QAM调制的符号流”,没有问题。
当我在代码中检查变量chnData中的值时,我会看到实数。当我在示例代码中检查变量chan中的值时,我会看到复数。我的密码怎么了?
PS:我正在开发R2012b,通讯工具箱版本是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发布于 2017-06-04 09:07:50
发现了错误!现在修好了。
modData = step(qamModulator, encData);
chnData = step(awgnChannel, encData); // Should have been modDatahttps://stackoverflow.com/questions/44295613
复制相似问题