Help for plotting graph. Can someone help me?

조회 수: 1(최근 30일)
adriane duarte
adriane duarte 2021년 6월 11일
편집: adriane duarte 2021년 6월 15일
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?

답변(1개)

Alan Stevens
Alan Stevens 2021년 6월 11일
In your while loop you don't update either nErrorsBitsW or nErrorsBitsInf so they always stay at 0, and never reach minNbits.
  댓글 수: 3
adriane duarte
adriane duarte 2021년 6월 15일
okay.
I will try to find a solution.

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

Community Treasure Hunt

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

Start Hunting!

Translated by