LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

for loops in LabVIEW

How do I implement the following nested for loops in LabVIEW?

for i = 0:4
for t = (i*period):((i + 1)*period)

Thanks.
0 Kudos
Message 1 of 3
(2,871 Views)
Easy... see example. Your second For loop always runs "period" times.

Daniel L. Press
www.primetest.com
Message 2 of 3
(2,871 Views)
Lei:

You can't really implement that code that exact way in LabVIEW.
LabVIEW loops only go from 0 to N-1. You can't move them around like
you can in other languages.

What you need to do to implement your code in LabVIEW is to have two
simple nested for loops and compute t using the math palette VI's from
the iteration counters (the little i's) INSIDE the loops. I think the
equivalent C code for what you want to do could be written as:

for (int i=0; i<4;++i)
{
for (int j=0; j {
int t=i*period+j;
//Do whatever that you want to do with t....

}
}

If you learn to think about it this way then you can get where you
want to go in LabVIEW.

Douglas De Clue
LabVIEW developer
ddeclue@bellsouth.net

(P.S. I'm not sure what your pseu
do code loop limits are i.e. do they
include the upper limit or not?)



Lei Dai wrote in message news:<506500000008000000694E0000-1023576873000@exchange.ni.com>...
> How do I implement the following nested for loops in LabVIEW?
>
> for i = 0:4
> for t = (i*period):((i + 1)*period)
>
> Thanks.
0 Kudos
Message 3 of 3
(2,871 Views)