Re: For Loop
- To: mathgroup at smc.vnet.net
- Subject: [mg44877] Re: For Loop
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Fri, 5 Dec 2003 05:31:49 -0500 (EST)
- Organization: Universitaet Leipzig
- References: <bqmr2o$r9t$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
the syntax for the For[] loop is
For[initial,test,increment, body]
if you nest for loops it should look like
For[initial1,test1, increment1,
For[initial2,test2, increment2, body]
]
but your code execute the innter loops in the initialization
part of the first loop ...
Regards
Jens
"Sheth, Payal R." wrote:
>
>
> I am trying to solve for pTyr50for100 this FOR loop with three
> different variables (KmPdephos,Kcatautophos, Kcatphos). I basically
> want to calculate the value of pTyr50for100 for different combinations
> of these variables as defined in the loop However, once the innner loop
> is completed the value of the inner loop variable remains steady at the
> final value and that loop is exited. There is a logical error in this
> code which I havent been able to find and I was hoping someone could
> help me with it. To make things clearer heres the code
>
> For[dimKcatautophos = 0.0008;
> For[dimKmPdephos = 0.01;
> For[dimKcatphos = 0.008; ndsolutioncombined, dimKcatphos < 0.8,
> dimKcatphos += 0.1, pTyr50for100 = {dimKcatautophos/0.0008, \
> dimKmPdephos/0.01, dimKcatphos/0.008, ((Lphos[50] /.
> ndsolutioncombined)/3)*100}; Print[pTyr50for100]],
> dimKmPdephos < 1, dimKmPdephos += 0.3, pTyr50for100 = \
> {dimKcatautophos/0.0008,
> dimKmPdephos/0.01, dimKcatphos/0.008, ((Lphos[50] /. \
> ndsolutioncombined)/
> 3)*100}; Print[pTyr50for100]],
> dimKcatautophos < 0.08, dimKcatautophos += .1,
> pTyr50for100 = {dimKcatautophos/0.0008, dimKmPdephos/0.01,
> dimKcatphos/0.008, ((Lphos[50] /. ndsolutioncombined)/3)*100}; Print[
> pTyr50for100]]
>
>
> ndsolution:= a set of 20 differential equations
>
> The output from this is
>
> 0.0008, 0.01, 0.008, {value at this condition)
> 0.0008, 0.01, 0.108, {value at this condition)
> 0.0008, 0.01, 0.208, {value at this condition}
> ... 0.308 .......... Here the
> Value of inner loop is changing as anticipated
> .... ......... 0.408............
> .... ........... 0.508................
> .................. 0.608
> .... 0.708
> ...... 0.808
> 0.0008, 0.31, 0.808 But here I would
> expect the inner loop to be evaluated after the increment in the middle loop
> 0.0008, 0.61, 0.808 Instead the
> inner loop value is constant (max value) and middle loop is evaluated
> .
> ..
> ...
> ...
> 0.0008, 1.21, 0.808... Again I expect the
> outer loop to be evaluated at different values of middle and inner loop.
> 0.0108, 1.21, 0.808....
> 0.0208, 1.21, 0.808
>
>
> I would expect my results to be something like this
>
> 0.0008, 0.01, 0.008, value
>
> until the inner loop is satisfied ie
>
> 0.0008, 0.01, 0.808 and then
>
> 0.0008, 0.31, 0.008
>
> 0.0008, 0.31, 0.108
>
> again until inner loop is completed
>
> and then ...
>
> 0.0008, 0.61, 0.008
>
> and so on...I hope you get the picture.
>
>
>
> Can someone tell me where I am going wrong in the logic?
>
>
>
> Any help whatsoever will be appreciated
>
>
>
> Thanks much
>
>
>
>
>
>