how can I plot using the while loop

I am trying to generate a code that will plot(e,n) ; e=error and n= throughput efficacy . Any how I have written this code for now, but I can not check it because I can't see the value of n.
i=0;
bits=32;%length of bits in the packet
for e=0:0.05:0.5
packet=round(rand(1,bits));% to make sure the random numbers in the packet contain 1's or 0's in an array
ndata =bsc(packet,e);
totbits=bits;
cbits=bits;
n=cbits/totbits; %correct bits over total bits
while packet~=ndata
ndata =bsc(packet,e);
i=i+1;
j=abs(packet-ndata);
s=sum(j,2);
c=bits-s;
cbits=cbits+c;
totbits=totbits+bits;
n=cbits/totbits %correct bits over total bits
end
end
plot(e,n)
grid on
I need help, to know how can I see the value of n to compare it with the real value, to make sure my code is correct before i Plot. and secondly, how can i plot n for each e, since n will be different for each e.

1 Kommentar

KSSV
KSSV am 22 Apr. 2017
Your while loop doesn't work..you are comparing two matrices packet and ndata. Check your code properly.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 22 Apr. 2017

0 Stimmen

You'd need to index n inside the loop
n(i) = cbits/totbits
and recreate e before plotting
e = 0 : 0.05 : 0.5;
plot(e, n, 'b*-', 'LineWidth', 2);
grid on;

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 21 Apr. 2017

Beantwortet:

am 22 Apr. 2017

Community Treasure Hunt

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

Start Hunting!

Translated by