필터 지우기
필터 지우기

Error in coding

조회 수: 2 (최근 30일)
Sherif
Sherif 2011년 3월 26일
The following code taken from
is not workign , plese some one help me to make it work. Two errors were displayed.
EbNo = 2:0.5:8; % information rate Eb/No in dB
codeRate = 1/2; % code rate of convolutional encoder
nBits = 4; % number of bits in a 16-QAM symbol
Pavg = 10; % average signal power of a 16-QAM modulated si
gnal
snr = EbNo - 10*log10(1/codeRate) + 10*log10(nBits); % SNR in dB
noiseVarVector = Pavg ./ (10.^(snr./10)); % noise variance
% Initialize variables for storing the BER results
ber_HD = zeros(1, length(EbNo));
ber_SD = zeros(1, length(EbNo));
ber_LLR = zeros(1, length(EbNo));
% Loop over all noiseVarVector values
for idx=1:length(noiseVarVector)
noiseVar = noiseVarVector(idx);
sim(modelName);
% Collect BER results
ber_HD(idx) = BER_HD(1);
ber_SD(idx) = BER_SD(1);
ber_LLR(idx) = BER_LLR(1);
end
% Perform curve fitting and plot the results
fitBER_HD = real(berfit(EbNo, ber_HD));
fitBER_SD = real(berfit(EbNo, ber_SD));
fitBER_LLR = real(berfit(EbNo, ber_LLR));
semilogy(EbNo, ber_HD, 'r*', ...
EbNo, ber_SD, 'g*', ...
EbNo, ber_LLR, 'b*', ...
EbNo, fitBER_HD, 'r', ...
EbNo, fitBER_SD, 'g', ...
EbNo, fitBER_LLR, 'b');
legend('Hard Decision Decoding','Soft Decision Decoding','Unquantized Decodi
ng');
xlabel('Eb/No (dB)'); ylabel('BER');
title('LLR vs. Hard Decision Demodulation with Viterbi Decoding');
grid on;
  댓글 수: 1
Matt Fig
Matt Fig 2011년 3월 26일
It is always helpful to give more information rather than less. For example, what did the error messages say? Copy and paste the error messages.

댓글을 달려면 로그인하십시오.

답변 (3개)

Matt Fig
Matt Fig 2011년 3월 26일
Do have the correct toolboxes? Did you format the code correctly? It looks like there is some wrapping going on even on the page you got it from. Try this:
EbNo = 2:0.5:8;
codeRate = 1/2;
nBits = 4;
Pavg = 10;
snr = EbNo - 10*log10(1/codeRate) + 10*log10(nBits);
noiseVarVector = Pavg ./ (10.^(snr./10)); % noise variance
% Initialize variables for storing the BER results
ber_HD = zeros(1, length(EbNo));
ber_SD = zeros(1, length(EbNo));
ber_LLR = zeros(1, length(EbNo));
% Loop over all noiseVarVector values
for idx=1:length(noiseVarVector)
noiseVar = noiseVarVector(idx);
sim(modelName);
% Collect BER results
ber_HD(idx) = BER_HD(1);
ber_SD(idx) = BER_SD(1);
ber_LLR(idx) = BER_LLR(1);
end
% Perform curve fitting and plot the results
fitBER_HD = real(berfit(EbNo, ber_HD));
fitBER_SD = real(berfit(EbNo, ber_SD));
fitBER_LLR = real(berfit(EbNo, ber_LLR));
semilogy(EbNo, ber_HD, 'r*', ...
EbNo, ber_SD, 'g*', ...
EbNo, ber_LLR, 'b*', ...
EbNo, fitBER_HD, 'r', ...
EbNo, fitBER_SD, 'g', ...
EbNo, fitBER_LLR, 'b');
legend('Hard Decision','Soft Decision','Unquantized Decoding');
xlabel('Eb/No (dB)'); ylabel('BER');
title('LLR vs. Hard Decision Demodulation with Viterbi Decoding');
grid on;

Sherif
Sherif 2011년 3월 26일
that coding was also not working, following error message has occoured.
??? Undefined function or variable 'modelName'.
Error in ==> Untitled4 at 16 sim(modelName);
can you please correct it ..?

Walter Roberson
Walter Roberson 2011년 3월 26일
You appear to have missed the part before the diagram on that page:
modelName = 'commLLRvsHD';
open_system(modelName);

카테고리

Help CenterFile Exchange에서 Modulation에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by