EMPBER must be a real vector between 0 and 1
1 view (last 30 days)
Show older comments
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 Comment
Answers (1)
Chetan
on 7 Sep 2023
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
0 Comments
See Also
Categories
Find more on Test and Measurement in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!