Help for plotting graph. Can someone help me?

2 vues (au cours des 30 derniers jours)
adriane duarte
adriane duarte le 11 Juin 2021
Modifié(e) : adriane duarte le 15 Juin 2021
Good night people.
I'm having difficulty plotting two graphs referring to my code.
The code is below:
clear all;
close all;
clc;
% number of bits
L = 1e4;
N = 1;
M = L/N;
u = [ ones(1,N) ];
alpha = 0.3;
% LED information
Vt = 0.5;
Is = 0.12;
% LED model
K = 0.8;
imax = 0.5;
threshold = 150;
sigmaV2 = (imax/threshold)^2;
% Signal to Noise Ratio (in dB)
SNRdB = -10:2:32;
SNR = 10.^(SNRdB/10);
% standard deviation of the signal (power)
sigmaX2v = SNR*sigmaV2;
alphaICS = 0.3;
% Minimum number of bits for BER calculation
minNbits = 500;
for count=1:length(SNRdB)
an = 2*randi([ 0 1 ],1,L)-1;
bn = 2*randi([ 0 1 ],1,L)-1;
dI = 2*randi([ 0 1 ],1,L)-1;
dQ = 2*randi([ 0 1 ],1,L)-1;
sn = an.*(sqrt(1-alpha) + sqrt(alpha).*dI) +1i.*bn.*(sqrt(1-alpha) + sqrt(alpha).*dQ);
sn1 = sn.';
Y = sn1; % transmitter
stdS = std(Y);
X = zeros(1,4*L);
X(2:2:end) = [Y; conj(Y(end:-1:1))];
xTD = ifft(X);
xTD = (sqrt(sigmaX2v(count)))*xTD/std(xTD);
xx = xTD;
ind = find(xTD < 0);
xx(ind) = zeros(size(ind));
ss = xx;
iLED = Is*(exp(ss/Vt)-1);
xLED = iLED./( (1 + (iLED/imax).^(2*K)).^(1/(2*K)));
nErrorsBitsInf = 0;
nErrorsBitsW = 0;
cont = 0;
while ( (nErrorsBitsW < minNbits) || (nErrorsBitsInf < minNbits))
cont = cont + 1;
v = sqrt(sigmaV2)*randn(size(xx));
y = xLED + v;
Nframe = length(y);
Xhat = (fft(y));
Shat = Xhat(2:2:Nframe/2);
Shat = stdS*Shat/std(Shat); % receiver
end
end
I would like to plot two separate figures: one with the result of the receiver (Shat) and the other of the transmitter (Y).
I have a model chart below.
I would like to plot the graph this way (with the bits in the caption and separated by markers)
I accept any idea (using loop or not).
I've tried everything but couldn't get the desired result.
Can someone help me?

Réponses (1)

Alan Stevens
Alan Stevens le 11 Juin 2021
In your while loop you don't update either nErrorsBitsW or nErrorsBitsInf so they always stay at 0, and never reach minNbits.
  3 commentaires
Alan Stevens
Alan Stevens le 13 Juin 2021
Presumably, nErrorsBitsW and nErrorsBitsInf depend on something calculated within the while loop. You need to recalculate them within the loop using that. I don't know what they depend on, so can't be more specific.
adriane duarte
adriane duarte le 15 Juin 2021
okay.
I will try to find a solution.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by