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 件のコメント
KSSV
2017 年 4 月 22 日
Your while loop doesn't work..you are comparing two matrices packet and ndata. Check your code properly.
回答 (1 件)
Image Analyst
2017 年 4 月 22 日
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;
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!