f



Triple nested loop python (While loop insde of for loop inside of while loop)

try to make my triple nested loop working. My code would be:
c = 4    
y1 = []    
m1 = []    
std1 = []    
while c <24:    
        c = c + 1    
        a = []    
        f.seek(0,0)    
        for columns in ( raw.strip().split() for raw in f ):    
                a.append(columns[c])    
                x = np.array(a, float)    
        not_nan = np.logical_not(np.isnan(x))    
        indices = np.arange(len(x))    
        interp = interp1d(indices[not_nan], x[not_nan], kind = 'nearest')    
        p = interp(indices)

        N = len(p)    
        dt = 900.0 #Time step (seconds)    
        fs = 1./dt #Sampling frequency    
        KA,PSD = oned_Fourierspectrum(p,dt) # Call Song's 1D FS function    
        time_axis = np.linspace(0.0,N,num = N,endpoint = False)*15/(60*24)     
        plot_freq = 24*3600.*KA #Convert to cycles per day     
        plot_period = 1.0/plot_freq # convert to days/cycle    
        fpsd = plot_freq*PSD    
        d = -1     
        while d <335:     
                d = d + 1     
                y = fpsd[d]     
                y1 = y1 + [y]       
               m = np.mean(y1)
        m1 = m1 + [m]
print m1
--------------------------------------------------------------------------------

My purpose is make a list of [mean(fpsd[0]), mean(fpsd[1]), mean(fpsd[2]).. mean(fpsd[335])]. Each y1 would be the list of fpsd[d].

I check it is working pretty well before second while loop and I can get individual mean of fpsd[d]. However, with second whole loop, it produces definitely wrong numbers. Would you help me this problem?
0
winefrog (28)
3/1/2013 8:59:59 AM
comp.lang.python 77058 articles. 3 followers. Post Follow

9 Replies
1952 Views

Similar Articles

[PageSpeed] 9

Am 01.03.2013 09:59, schrieb Isaac Won:
> try to make my triple nested loop working. My code would be:
> c = 4
[...]
> while c <24:
>          c = c + 1

This is bad style and you shouldn't do that in python. The question that 
comes up for me is whether something else is modifying "c" in that loop, 
but I think the answer is "no". For that reason, use Python's way:

   for c in range(5, 25):
       ...

That way it is also clear that the first value in the loop is 5, while 
the initial "c = 4" seems to suggest something different. Also, the last 
value is 24, not 23.



>          while d <335:
>                  d = d + 1
>                  y = fpsd[d]
>                  y1 = y1 + [y]
>                 m = np.mean(y1)
>          m1 = m1 + [m]

Apart from the wrong indention (don't mix tabs and spaces, see PEP 8!) 
and the that "d in range(336)" is better style, you don't start with an 
empty "y1", except on the first iteration of the outer loop.

I'm not really sure if that answers your problem. In any case, please 
drop everything not necessary to demostrate the problem before posting. 
This makes it easier to see what is going wrong both for you and others. 
Also make sure that others can actually run the code.


Greetings from Hamburg!

Uli



0
3/1/2013 12:00:42 PM
--bcaec54d4cfcd4687c04d6dc95c2
Content-Type: text/plain; charset=UTF-8

On Fri, Mar 1, 2013 at 7:00 AM, Ulrich Eckhardt <
ulrich.eckhardt@dominolaser.com> wrote:

> Am 01.03.2013 09:59, schrieb Isaac Won:
>
>  try to make my triple nested loop working. My code would be:
>> c = 4
>>
> [...]
>
>  while c <24:
>>          c = c + 1
>>
>
> This is bad style and you shouldn't do that in python. The question that
> comes up for me is whether something else is modifying "c" in that loop,
> but I think the answer is "no". For that reason, use Python's way:
>
>   for c in range(5, 25):
>       ...
>
> That way it is also clear that the first value in the loop is 5, while the
> initial "c = 4" seems to suggest something different. Also, the last value
> is 24, not 23.
>
>
>
> I concur with Uli, and add the following thoughts:  What is going on with
[y]?  Is this really a list?  So what is y1 + y1 + [y] doing?

>
>           while d <335:
>>                  d = d + 1
>>                  y = fpsd[d]
>>                  y1 = y1 + [y]
>>                 m = np.mean(y1)
>>          m1 = m1 + [m]
>>
>
> In your outer loop you initialize these values each pass:

        dt = 900.0 #Time step (seconds)
        fs = 1./dt #Sampling frequency

This should me moved out of the loop since nothing changes with dt or fs



> Apart from the wrong indention (don't mix tabs and spaces, see PEP 8!) and
> the that "d in range(336)" is better style, you don't start with an empty
> "y1", except on the first iteration of the outer loop.
>
> I'm not really sure if that answers your problem. In any case, please drop
> everything not necessary to demostrate the problem before posting. This
> makes it easier to see what is going wrong both for you and others. Also
> make sure that others can actually run the code.
>
>
> Greetings from Hamburg!
>
> Uli
>
>
>
> --
> http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list>
>



-- 
Joel Goldstick
http://joelgoldstick.com

--bcaec54d4cfcd4687c04d6dc95c2
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">On Fri, Mar 1, 2013 at 7:00 AM, Ulrich Eckhardt <span dir=3D"ltr">&=
lt;<a href=3D"mailto:ulrich.eckhardt@dominolaser.com" target=3D"_blank">ulr=
ich.eckhardt@dominolaser.com</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left:1px solid rgb(204,204,204);padding-left:1ex">Am 01.03.2013 09:59, schr=
ieb Isaac Won:<div class=3D"im"><br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left:1px solid rgb(204,204,204);padding-left:1ex">
try to make my triple nested loop working. My code would be:<br>
c =3D 4<br>
</blockquote></div>
[...]<div class=3D"im"><br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left:1px solid rgb(204,204,204);padding-left:1ex">
while c &lt;24:<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0c =3D c + 1<br>
</blockquote>
<br></div>
This is bad style and you shouldn&#39;t do that in python. The question tha=
t comes up for me is whether something else is modifying &quot;c&quot; in t=
hat loop, but I think the answer is &quot;no&quot;. For that reason, use Py=
thon&#39;s way:<br>

<br>
=C2=A0 for c in range(5, 25):<br>
=C2=A0 =C2=A0 =C2=A0 ...<br>
<br>
That way it is also clear that the first value in the loop is 5, while the =
initial &quot;c =3D 4&quot; seems to suggest something different. Also, the=
 last value is 24, not 23.<div class=3D"im"><br>
<br>
<br></div></blockquote><div>I concur with Uli, and add the following though=
ts:=C2=A0 What is going on with [y]?=C2=A0 Is this really a list?=C2=A0 So =
what is y1 + y1 + [y] doing? <br></div><blockquote class=3D"gmail_quote" st=
yle=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padd=
ing-left:1ex">
<div class=3D"im">
<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left:1px solid rgb(204,204,204);padding-left:1ex">
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0while d &lt;335:<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0d =3D d + 1<b=
r>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0y =3D fpsd[d]=
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0y1 =3D y1 + [=
y]<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 m =3D np.mean(y1)<b=
r>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0m1 =3D m1 + [m]<br>
</blockquote>
<br></div></blockquote><div>In your outer loop you initialize these values =
each pass:<br><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 dt =3D 900.0 #Time step (seco=
nds)<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 fs =3D 1./dt #Sampling frequency<br>
<br></div><div>This should me moved out of the loop since nothing changes w=
ith dt or fs<br></div><div><br>=C2=A0</div><blockquote class=3D"gmail_quote=
" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);=
padding-left:1ex">
<div class=3D"im"></div>
Apart from the wrong indention (don&#39;t mix tabs and spaces, see PEP 8!) =
and the that &quot;d in range(336)&quot; is better style, you don&#39;t sta=
rt with an empty &quot;y1&quot;, except on the first iteration of the outer=
 loop.<br>

<br>
I&#39;m not really sure if that answers your problem. In any case, please d=
rop everything not necessary to demostrate the problem before posting. This=
 makes it easier to see what is going wrong both for you and others. Also m=
ake sure that others can actually run the code.<br>

<br>
<br>
Greetings from Hamburg!<br>
<br>
Uli<span class=3D""><font color=3D"#888888"><br>
<br>
<br>
<br>
-- <br>
<a href=3D"http://mail.python.org/mailman/listinfo/python-list" target=3D"_=
blank">http://mail.python.org/<u></u>mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br><br clear=3D"all"><br>-- <br><div dir=
=3D"ltr"><div>Joel Goldstick<br></div><a href=3D"http://joelgoldstick.com" =
target=3D"_blank">http://joelgoldstick.com</a><br></div>
</div></div>

--bcaec54d4cfcd4687c04d6dc95c2--
0
3/1/2013 1:00:01 PM
On Fri, Mar 1, 2013 at 7:59 PM, Isaac Won <winefrog@gmail.com> wrote:
> while c <24:
>         for columns in ( raw.strip().split() for raw in f ):
>         while d <335:

Note your indentation levels: the code does not agree with your
subject line. The third loop is not actually inside your second.
Should it be?

ChrisA
0
rosuav (4324)
3/1/2013 1:41:05 PM
Thank you, Chris.
I just want to acculate value from y repeatedly.
If y = 1,2,3...10, just have a [1,2,3...10] at onece.
On Friday, March 1, 2013 7:41:05 AM UTC-6, Chris Angelico wrote:
> On Fri, Mar 1, 2013 at 7:59 PM, Isaac Won <winefrog@gmail.com> wrote:
> 
> > while c <24:
> 
> >         for columns in ( raw.strip().split() for raw in f ):
> 
> >         while d <335:
> 
> 
> 
> Note your indentation levels: the code does not agree with your
> 
> subject line. The third loop is not actually inside your second.
> 
> Should it be?
> 
> 
> 
> ChrisA

0
winefrog (28)
3/1/2013 4:14:03 PM
Thank you, Chris.
I just want to acculate value from y repeatedly.
If y = 1,2,3...10, just have a [1,2,3...10] at onece.
On Friday, March 1, 2013 7:41:05 AM UTC-6, Chris Angelico wrote:
> On Fri, Mar 1, 2013 at 7:59 PM, Isaac Won <winefrog@gmail.com> wrote:
> 
> > while c <24:
> 
> >         for columns in ( raw.strip().split() for raw in f ):
> 
> >         while d <335:
> 
> 
> 
> Note your indentation levels: the code does not agree with your
> 
> subject line. The third loop is not actually inside your second.
> 
> Should it be?
> 
> 
> 
> ChrisA

0
winefrog (28)
3/1/2013 4:14:03 PM
On Friday, March 1, 2013 7:41:05 AM UTC-6, Chris Angelico wrote:
> On Fri, Mar 1, 2013 at 7:59 PM, Isaac Won <winefrog@gmail.com> wrote:
> 
> > while c <24:
> 
> >         for columns in ( raw.strip().split() for raw in f ):
> 
> >         while d <335:
> 
> 
> 
> Note your indentation levels: the code does not agree with your
> 
> subject line. The third loop is not actually inside your second.
> 
> Should it be?
> 
> 
> 
> ChrisA

Yes, the thiird lood should be inside of my whole loop.
Thank you,
Isaac
0
winefrog (28)
3/1/2013 4:18:54 PM
On Friday, March 1, 2013 7:41:05 AM UTC-6, Chris Angelico wrote:
> On Fri, Mar 1, 2013 at 7:59 PM, Isaac Won <winefrog@gmail.com> wrote:
> 
> > while c <24:
> 
> >         for columns in ( raw.strip().split() for raw in f ):
> 
> >         while d <335:
> 
> 
> 
> Note your indentation levels: the code does not agree with your
> 
> subject line. The third loop is not actually inside your second.
> 
> Should it be?
> 
> 
> 
> ChrisA

Yes, the thiird lood should be inside of my whole loop.
Thank you,
Isaac
0
winefrog (28)
3/1/2013 4:18:54 PM
Thank you Ulich for reply,
What I really want to get from this code is m1 as I told. For this purpose, for instance, values of fpsd upto second loop and that from third loop should be same, but they are not. Actually it is my main question.
Thank you,
Isaac
On Friday, March 1, 2013 6:00:42 AM UTC-6, Ulrich Eckhardt wrote:
> Am 01.03.2013 09:59, schrieb Isaac Won:
> 
> > try to make my triple nested loop working. My code would be:
> 
> > c = 4
> 
> [...]
> 
> > while c <24:
> 
> >          c = c + 1
> 
> 
> 
> This is bad style and you shouldn't do that in python. The question that 
> 
> comes up for me is whether something else is modifying "c" in that loop, 
> 
> but I think the answer is "no". For that reason, use Python's way:
> 
> 
> 
>    for c in range(5, 25):
> 
>        ...
> 
> 
> 
> That way it is also clear that the first value in the loop is 5, while 
> 
> the initial "c = 4" seems to suggest something different. Also, the last 
> 
> value is 24, not 23.
> 
> 
> 
> 
> 
> 
> 
> >          while d <335:
> 
> >                  d = d + 1
> 
> >                  y = fpsd[d]
> 
> >                  y1 = y1 + [y]
> 
> >                 m = np.mean(y1)
> 
> >          m1 = m1 + [m]
> 
> 
> 
> Apart from the wrong indention (don't mix tabs and spaces, see PEP 8!) 
> 
> and the that "d in range(336)" is better style, you don't start with an 
> 
> empty "y1", except on the first iteration of the outer loop.
> 
> 
> 
> I'm not really sure if that answers your problem. In any case, please 
> 
> drop everything not necessary to demostrate the problem before posting. 
> 
> This makes it easier to see what is going wrong both for you and others. 
> 
> Also make sure that others can actually run the code.
> 
> 
> 
> 
> 
> Greetings from Hamburg!
> 
> 
> 
> Uli

0
winefrog (28)
3/1/2013 4:28:21 PM
Am 01.03.2013 17:28, schrieb Isaac Won:
> What I really want to get from this code is m1 as I told. For this
> purpose, for instance, values of fpsd upto second loop and that from
> third loop should be same, but they are not. Actually it is my main
> question.

You are not helping yourself...


>> In any case, please drop everything not necessary to demostrate the
>> problem before posting. This makes it easier to see what is going
>> wrong both for you and others. Also make sure that others can
>> actually run the code.

Read this carefully, I didn't write that to fill up empty space. Also, 
read Eric S. Raymond's essay on asking smart questions (you can easily 
locate it online), which the problems with your question in a much more 
general way.


Uli


0
3/4/2013 10:08:47 AM
Reply:

Similar Artilces:

Nested FOR loops. (a loop within a loop)
I can't get my head around them. I have two MySQL tables, one contains the categories, the other contains the posts. Each post is linked to a category. Now I'm trying to display each post with a drop down menu that has the categories in it and have the category that the post is in selected. Here's my code for the drop down menu where my woes lie. for ($i=0; $i<count($posts); $i++) { for ($j=1; $j<=count($categories); $j++) { if ($j == $post[$i]['id']) { selected = ' selected="selected"'; } else { sele...

FOR loop not looping
I have the below script that uses 2 for loops. for some reason they loop is not looping ! /bin/ksh CURR_PATH='/main/nedcor/flexcube' cd $CURR_PATH for DIR1 in 'WIP' 'INPUT';do echo $DIR1 for DIR in $(find . -name $DIR1);do RESULT=`ls -A $DIR | egrep -v "BKUP|BKP"` echo $DIR echo $RESULT echo $RESULT1 if [ -z "$RESULT" ] ; then echo "No Files found" exit 0 else echo file $RESULT found exit 1 ...

loop not looping
This should be relatively easy for someone more experienced to pick out what I'm doing wrong here...All I want is my loop to run as many times as there are .dat files in the specified directory. I've hacked up my code a bit just so i can get it to work and realize it's not as simple or efficient as it could be. My script only runs through the loop once and I can't figure out why it never loads 'binary_002.dat' and so on. thanks for your help counter_value = 1; %counter value set back to 0 when while loop = false slice_thicknessMM = 1.5; tf = isdir('C:\Documen...

Loop in a loop?
Hi, I'm new to Python and have come across a problem I don't know how to solve, enter com.lang.python :) I'm writing some small apps to learn the language, and I like it a lot so far. My problem I've stumbled upon is that I don't know how to do what I want. I want to do a loop in a loop. I think. I've got two arrays with some random stuff in, like this. array1 = ['one','two','three','four'] array2 = ['a','b','c','d'] I want to loop through array1 and add elements from array2 at the end, so it looks lik...

for loop into for loop.
Hello this is my first time that i am writing here.. I need your help to improve my code. This is my code for a=1:numberOfShortestPaths for b=a+1:a+numberOfShortestPaths for c=b+1:b+numberOfShortestPaths for d=c+1:c+numberOfShortestPaths for e=d+1:d+numberOfShortestPaths total_weight=weight(:,:,a)+weight(:,:,b)+weight(:,:,c)+weight(:,:,d)+weight(:,:,e); maximum=max(total_weight); end end end end end i want to do this function "automatically" because the letters ...

WHILE LOOP AS FOR LOOP
its possible? For each id in (SELECT * FROM table) INSERT INTO table2(id,fk,nombre) values(1,id,'xxx'); Jessica Gonz�lez (jess.rgm@gmail.com) writes: > its possible? > > For each id in (SELECT * FROM table) > INSERT INTO table2(id,fk,nombre) > values(1,id,'xxx'); > So in SQL, you don't normally code the loops explicitly - the loops are hidden on the inside. Logically, it is an operation of a set. INSERT table(id, fk, nombre) SELECT 1, id, 'xxx' FROM table -- Erland Sommars...

loops in loops
In the attached vi, the one second loop runs at one second and can't be touched.&nbsp; In the ten second loop, the ten second clock is a stand in for a process that generates a finished signal. The problem is once the process is complete, to start it again, leave the one second loop running, and start an additional process that will take less time than 10 seconds. thanks internal loops.vi: http://forums.ni.com/attachments/ni/170/319512/1/internal loops.vi Hi exo, what do you try there? If you start your vi, the value from your stop button will be read and after that, both loops &quo...

For loop while loop
I need to evaluate a function from 0:200 then create an array of every 5th value in the 0:200 array using a for loop then using a while loop. I can't get the for loop to work at all because I cannot use >,< controllers, only an =. So I focused on the While loop: n=0:200;%creates 201 cell array from 0-200 x=n.^2+.25;%calculates x plotcol=(length(n)-1)/5;%=(201-1)/5=40 y=zeros(1,plotcol);%creates 1X40 vector col=1;%used for incrementing in while loop while col<=plotcol; y(1,col)=x(1,5*col); col=col+1; end Unfortunately the output starts at 16 when it should start ...

while loop in a while loop
Hi All, I have the following situation: while(rs.next()) { //loop1 while(rs2.next()) { //loop 2 } } It seems like loop 2 is only beeing used once. Should I after loop2 put the cursor back to the beginning? if so, how do I do that? Thanks! -- Posted by news://news.nb.nu Steven wrote: > Hi All, > > I have the following situation: > > > while(rs.next()) { //loop1 > > while(rs2.next()) { > //loop 2 > } > > } > The architypal loop (for a List eg ArrayList of Blah objects) is: for(It...

while loop in a while loop
Hi all, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I am trying to write a program with a while loop within another while loop. When I run the vi both while loops&nbsp; run but then only the inner while loop seems to update, I adjust controls and they have no effect on the indicators. &nbsp; Thanks.. You need to familiarize with the concept of dataflow programming. Run your VI in "execution highligthing" mode while watching the diagram and you'll get a better feeling on how things work. :) &nbsp; If both loops need to run in para...

LOOP and +LOOP
With LOOP, since the index (I) increases by 1 with each loop iteration, we can test for equality as a means to determine if it's time to exit the loop or not: : TEST 10 0 DO I . LOOP ; TEST 0 1 2 3 4 5 6 7 8 9 Here, when I gets to 10, the loop exits. It's not so easy with +LOOP, since the index can be changed by any arbitrary value on each iteration: : TEST 100 0 DO I . RANDOM +LOOP ; Here, we cannot test for equality. We have to test for crossing a boundary instead, at least as far as I can see. With that in mind, are these following results correct: : TEST 10 0 DO I . 1 +LOOP ...

For loop over a while loop
Hi, I am computing a quantity that depends on two variables. The computation itself is iterative (i'm using 3 while loops to compute it). Now i want to do a sensitivity analysis of the input variables and do a 3D plot where I can start making sense out of my results, however not sure how to write a for loop over these while loops to compute different combinations of what I define as my parametric space for my two input variables. Thanks in advance, Vash Please add a code example and/or more specific question.... ...

Nested While loop inside For loop
I have been coding in matlab for a while and I am confused about the below code: It seems like the "For loop" iterator variable "Index" does not update inside the "While loop". Please help me understand! I hate to assume this is some error induced on Matlab's end. ---------- CODE ------------ for Index = 390000:length(Stopxy) fprintf('Index: %d, \n',Index); while (Stopxy_YCoord(Index) < LowToHighThresh) fprintf('Index: %d, Yval: %f \n',Index,Stopxy_YCoord(Index)); Stopxy_YCoord(Index); Index = Index + 1; ...

while loop inside a for loop
Hi, can someone please tell me why "time" (t) is not updated correctly within the while loop? Please run this small code in your machine and you'll know what I'm taking about. What I want is: for t=1 run the "while loop" until iq<=(numberc-1) then t=2 run the "while loop" again until iq<=(numberc-1), and so on. Basically, this code runs through all the nonzero elements of A and attempts to divide them individually into two, once a certain time has passed. Please feel free to ask for clarifications. Many thanks in advance. A=[0 0 0 0 0 0 ...

nested loops only loop once
I am using two while loops that are nested. The first loop (post name) returns the full column of results, but the second (post modified) only returns the first row of the column. Is there another way I could write this to get both loops to complete fully? I am using the two while loops to pull data from different tables, and insert that data into a list that has html code surrounding each loop. while ($url = mysql_fetch_array($urls, MYSQL_ASSOC)) { $pn = $url['post_name']; while ($date = mysql_fetch_array($lmdate, MYSQL_ASSOC)) { $lm = $date['post_modified']; ...

while-loops nested in while-loop
Hi! I'm new to labview and I've got some problems. I want to program a control for a testing facility. therefore I want to program several while-loops&nbsp; nested in each other, according to a designed Nassi-Shneiderman-diagram. So if the stop condition for an inner while loop is true (e.g. measure device mistake), the program should jump out of that while loop in the next outer while-loop. is that possible? Thank you right now! Yes it is possible When you stop the inner loop, from inside the inner loop, just&nbsp;wire/pass an appropriate&nbsp;stop condition ( stop if tr...

Having trouble stopping a loop (or loop de loop de loop)
Hi again everyone, Here is my rather clunky code (and I know it is rather inefficient): ------------------------------------------------------------------------------------------------------------------------------ while e_t lt 2 do begin for x=4e003, 20e003, 4e003 do begin for c=0.006, 0.01, 0.004 do begin for o=(50*!pi/180), (70*!pi/180), (10*!pi/180) do begin v= (a*x) ind_small = where(file[1,*] lt 2*x,count) if count eq 0 then te_small=0 if count gt 0 then begin ext_small = file[*,ind_small] le_small= ext_small[1,*] te_small = total(le_small^3) endif ind_large = where(file[1,*] ge...

what diference between timed loop and while loop and for loop
If I want to count 2 second working in the loop and next then going out of the loop I don't know&nbsp;which the loop &nbsp;I can use Message Edited by Jairak on 07-26-2008 03:14 PM Why do you need a loop to count for 2 seconds? To learn more about LabVIEW it is recommended that you go through the tutorial(s) and look over the material in the NI Developer Zone's <a href="http://zone.ni.com/devzone/cda/tut/p/id/5054" target="_blank">Learning Center</a> which provides links to other materials and other tutorials. You can also take the <a href=...

Nested loops, does it run the inner loop first then the outer loop?
I wrote this simple code for i=1:6 for c=1:6 fprintf('%i\n c:',c); fprintf('%i\n i:',i); end end and got the following output c:1 i:2 c:1 i:3 c:1 i:4 c:1 i:5 c:1 i:6 c:1 i:1 c:2 i:2 c:2 i:3 c:2 i:4 c:2 i:5 c:2 i:6 c:2 i:1 c:3 i:2 c:3 i:3 c:3 i:4 c:3 i:5 c:3 i:6 c:3 i:1 c:4 i:2 c:4 i:3 c:4 i:4 c:4 i:5 c:4 i:6 c:4 i:1 c:5 i:2 c:5 i:3 c:5 i:4 c:5 i:5 c:5 i:6 c:5 i:1 c:6 i:2 c:6 i:3 c:6 i:4 c:6 i:5 c:6 ...

nest an each loop within an each loop??
I have this each function: jQuery(function($){ $('#myCarousel img').each(function(index) { var imgWidth=$('#myCarousel img').width(); alert(imgWidth); $this = $(this).wrap('<div class="img-caption" style="width:' + imgWidth + 'px; float:left;" />'); $('<p>' + $this.attr("title") + '</p>').insertAfter($this); }); }); How and where do I nest this 2nd each loop inside the first one?? Both must run and they are looking for different image IDs. It does not work to try having them run ...

Ending a while loop inside a while loop
How do I make a while loop run as long as the while loop that contains it is running? I tried wiring both conditional terminals to a stop button in the outer loop, but that doesnt seem to work? Is there another way? &nbsp; Thanks. It doesn't work because of data dependency. Once you are inside the inner loop the outer loop will not go to the next iteration until the inner loop is done. It sounds to me like you want parallel loops running, rather than one inside the other. If you open the Example Finder (Help -&gt; Find Examples), and search for "loops", open the examples...

Converting a nested for loop to a while loop.
I am working on a problem where I need to convert a nested for loop to a while loop. I've got the problem partially solved but I was only able to get the code to initialize the first row of the Array. Where am I going wrong? Here is the initial code that I made for the for loop: A = [3 5 4;-8 -1 33;-17 6 -9]; B = zeros(size(A)) for i = 1:1:size(A,1) for j = 1:1:size(A,2) if(A(i,j) >= 1) B(i,j)=A(i,j)+20 else B(i,j)=log(A(i,j)) end end end Here is what I came up for the while loop: B = zeros(size(A)); i = 0; j = 0; while i < size(A,1) ...

parfor loop with nested for loop
Hi all, I'm new to this group, but googling my problem always points here so I thought I'd sign up. I'm running multiple iterations of a time-evolving Monte Carlo simulation in Matlab. Since each iteration is initialized randomly at the first time point, the iterations can safely be run in parallel on a quad core PC. I've previously been doing this by simply running 4 simultaneous Matlab sessions on one machine, but I thought I would save my institution some licenses and automate the process at the same time. The problem is that my code essentially has multiple nested for ...

nesting for loops in a parfor loop
Hi, I am trying to nest several for loops in a parfor loop. I have even read the documentation and several other queries/replies before posting here. I have a large dataset that I need to iterate over, calculating a property which would result in a prohibitively large array if I sent each answer to a separate element, and doing this on one cpu will take a prohibitively long time. Instead, what I am doing is reducing the array by another property, and then combining the calculated results in bins of this second property (essentially making a histogram). The parfor section of my cod...

Web resources about - Triple nested loop python (While loop insde of for loop inside of while loop) - comp.lang.python

Triple deity - Wikipedia, the free encyclopedia
A triple deity (sometimes referred to as threefold, tripled, triplicate, tripartite, triune or triadic, or as a trinity) is a deity associated ...

Gerard Baden-Clay ‘friends’ with triple murderer in jail - The Courier-Mail Search Search
CONVICTED wife killer Gerard Baden-Clay has struck up a friendship with triple murderer Massimo “Max” Sica as he waits to see whether his murder ...

WA Police to triple number of covert hoon cameras hidden on Perth streets
THE number of covert cameras available to police to catch hoons in our suburbs will immediately be tripled.

Police investigate whether alcohol a factor in triple fatality crash in Marayong
Police are investigating whether a driver was highly intoxicated at the time he sped off from police and crashed into a power pole, leaving three ...

WA fires: Murray Cowper hits back at WA Police Commissioner over triple-0 call
Liberal MP Murray Cowper defends his decision to call triple-0 to get support for exhausted firefighters in the South West.

WA fires: Murray Cowper hits back at WA Police Commissioner over triple-0 call
Liberal MP Murray Cowper defends his decision to call triple-0 to get support for exhausted firefighters in the South West.

Wonthaggi drowning: Confusing information given to triple-0 may have delayed ambulance dispatch
Confusing information given to triple-0 may have delayed the dispatch of an ambulance to a beach near Wonthaggi where a 13-year-old girl died. ...

Canada’s bombing mission over by Feb. 22; training mission to triple
Liberals announce that the complement of military personnel in the region will climb to 830, up from the current 650

Cost of fixing never-used Mat-Su ferry triples to $3M
The Mat-Su Assembly learned this week that repairs to the engines of the borough’s beleaguered, never-used ferry could cost nearly three times ...

Senate Republicans triple down on SCOTUS obstruction
Senate Republicans have spent the day digging in their heels even deeper against allowing President Obama to appoint a replacement for Antonin ...

Resources last updated: 2/24/2016 11:36:22 AM