[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: while/for statement — what's wrong in a co de?
From: |
Liam Groener |
Subject: |
Re: while/for statement — what's wrong in a co de? |
Date: |
Sat, 30 Apr 2011 03:34:07 -0700 |
Sent from my iPad
On Apr 30, 2011, at 3:21 AM, alhaim <address@hidden> wrote:
> I should have mention it before -- p is set to 0.01 at the beginning.
>
> The whole code goes like this:
>
>
> sens = 0.1;
> p = 0.1;
>
> %K = 1;
>
> %ceil(log_2 K)+ 1/[1-(1-p)^K]
> for K= 1:10
> while ( p < 1 )
> ceil(log2(K)) + 1/(1-(1-p)^K)
> p = p + sens;
> K
> endwhile;
> endfor
>
> K--
> View this message in context:
> http://octave.1599824.n4.nabble.com/while-for-statement-what-s-wrong-in-a-code-tp3485616p3485642.html
> Sent from the Octave - General mailing list archive at Nabble.com.
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave
Yep, but the p=0.1 should be the first statement in the for loop, just before
the while statement. Otherwise p will always be greater than 1 for K greater
than 1.