Error in coding
20 ビュー (過去 30 日間)
古いコメントを表示
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
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
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;
0 件のコメント
Walter Roberson
2011 年 3 月 26 日
You appear to have missed the part before the diagram on that page:
modelName = 'commLLRvsHD';
open_system(modelName);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Modulation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!