EMPBER must be a real vector between 0 and 1

2 Ansichten (letzte 30 Tage)
Sowmika M
Sowmika M am 10 Jun. 2022
Beantwortet: Chetan am 7 Sep. 2023
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 Kommentar
dpb
dpb am 10 Jun. 2022
At a BARE minimum, format the code to be at least legible.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Chetan
Chetan am 7 Sep. 2023
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

Kategorien

Mehr zu Test and Measurement finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by