i have a for loop which generates the BERR, and Received power, i want to find the number of times the if else statement is true,so to draw a bar graph, could anyone help me out?

2 ビュー (過去 30 日間)
if BERR<10^-5
display ('pass stage 1')
if PRx>-78
display ('pass stage 2')
else
display ('fail')
end
else
display ('fail')
end

採用された回答

Walter Roberson
Walter Roberson 2012 年 7 月 3 日
passed1 = 0;
passed2 = 0;
fail1 = 0;
fail2 = 0;
if BERR<10^-5
display ('pass stage 1')
if PRx>-78
display ('pass stage 2')
passed2 = passed2 + 1;
else
display ('fail')
fail2 = fail2 + 1;
end
else
display ('fail')
fail1 = fail1 + 1;
end
Myself, I'd probably be thinking in terms of
passed = sum( (BERR<10^(-5)) & (PRx > -78) );
  2 件のコメント
Schamun
Schamun 2012 年 7 月 9 日
編集済み: Walter Roberson 2012 年 7 月 9 日
thnk you Mr.Walter Roberson for the reply, it has been most helpful. ive got another question, say i have 3 different received powers,PRx1,PRx2,PRx3 generated,and for each PRX value i have a BERR generated in the loop,my question is, how do i compare each of these BERR values to their respective PRx value to do the same task as above
this is the code that i have
edtberr=reshape(berra.',3,[]); %so that each row will be BERR values for one of the PRX value
if edtberr(1,:)<10^-5
display ('pass stage 1')
if PRx(!)>-78
display ('pass stage 2')
success= success+1;
else
display ('fail')
fail=fail+1;
end
else
display ('fail')
end
Walter Roberson
Walter Roberson 2012 年 7 月 9 日
An evaluated expression is true when the result is nonempty and contains all nonzero elements (logical or real numeric). Otherwise, the expression is false.
With that emphasized, please reconsider "if edtberr(1,:)<10^-5"

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by