EMPBER must be a real vector between 0 and 1

조회 수: 1 (최근 30일)
Sowmika M
Sowmika M 2022년 6월 10일
답변: Chetan 2023년 9월 7일
clc; clear all; close all; convEncoder = comm.ConvolutionalEncoder(poly2trellis(7, [171 133])); convEncoder.PuncturePatternSource = 'Property'; convEncoder.PuncturePattern = [1;1;0;1;1;0]; bpskMod = comm.BPSKModulator; rayChan = comm.RayleighChannel('SampleRate',1e5,'MaximumDopplerShift',130); vitDecoder = comm.ViterbiDecoder(poly2trellis(7, [171 133]), ... 'InputFormat', 'Unquantized'); vitDecoder.PuncturePatternSource = 'Property'; vitDecoder.PuncturePattern = convEncoder.PuncturePattern; vitDecoder.TracebackDepth = 96; errorCalc = comm.ErrorRate('ReceiveDelay', vitDecoder.TracebackDepth); EbNoEncoderInput = 2:0.5:5;% in dB EbNoEncoderOutput = EbNoEncoderInput + 10*log10(3/4); frameLength = 45; % this value must be an integer multiple of 3 targetErrors = 12; maxNumTransmissions = 5e6; BERVec = zeros(3,length(EbNoEncoderOutput));% Allocate memory to store results for n=1:length(EbNoEncoderOutput) reset(errorCalc) reset(convEncoder) reset(vitDecoder) channel.EbNo = EbNoEncoderOutput(n); % Set the channel EbNo value for simulation while (BERVec(2,n) < targetErrors) && (BERVec(3,n) < maxNumTransmissions) % Generate binary frames of size specified by the frameLength variable data = randi([0 1], frameLength, 1); % Convolutionally encode the data encData = convEncoder(data); % Modulate the encoded data modData = bpskMod(encData); % Pass the modulated signal through an AWGN channel channelOutput = rayChan(modData); % Pass the real part of the channel complex outputs as the unquantized % input to the Viterbi decoder. decData = vitDecoder(real(channelOutput)); % Compute and accumulate errors BERVec(:,n) = errorCalc(data, decData); end end dist = 5:11; nerr = [42 201 1492 10469 62935 379644 2253373]; codeRate = 3/4; bound = nerr*(1/6)*erfc(sqrt(codeRate*(10.0.^((2:.02:5)/10))'*dist))'; berfit(EbNoEncoderInput,BERVec(1,:)); % Curve-fitted simulation results hold on; semilogy((2:.02:5),bound,'g'); % Theoretical results legend('Empirical BER','Fit for simulated BER', 'Theoretical bound on BER'); axis([1 6 10^-5 1]) This is the code, i got a error in the line berfit(EbNoEncoderInput, BERVec(1,:)) EMPBER must be a real vector between 0 and 1.
  댓글 수: 1
dpb
dpb 2022년 6월 10일
At a BARE minimum, format the code to be at least legible.

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

답변 (1개)

Chetan
Chetan 2023년 9월 7일
Hello @Sowmika M,
I understand that you are facing issueswhile using the "berfit" function. The error you are encountering is likely due to the values in the vector not being within the exclusive range of 0 and 1.
To resolve this issue, it is important to ensure that the input vector provided to the "berfit" function contains values that are strictly between 0 and 1. If any values fall outside this range, it will result in an error.
I recommend referring to the documentation of the "berfit" function for more information and guidance on how to properly use the function:
I hope these suggestions help you resolve the issue you are facing.
Best regards,
Chetan Verma

카테고리

Help CenterFile Exchange에서 Test and Measurement에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by