Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

how to pick up indices for a for loop

hi guys , 

 

i have a for loop with N = 60 , i'm trying to make something when the index (i) reachs specific number , the indecies i'm interested in are

 

1 ,5 , 9,13, 17, 22, 26, ,30,34,38,43,47,51,55,59

 

the difference is 4 in some of them but it changes to 5 @ 22 and 43 and come back to 4 in between .

 

can anybody help me pick up these indecies ?

0 Kudos
Message 1 of 4
(5,279 Views)

Hi bmemq,

 

What's your application here? It sounds like you can use a case structure and wire the iteration terminal of the for loop to the selector. This will give you a default case as well as a case for what you want to do when the index is one of those numbers that you want.

Josh Y.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 4
(5,274 Views)

i want to do the same thing when the index happpens , basically change a boolean from T to F , so i'm courous, if i can find a way to check out weather the wanted index come out or not, mathamatically for example?

0 Kudos
Message 3 of 4
(5,272 Views)

Hi bmemq,

 

You can do this with the Equal? function found in the Comparison palette. You would have one Equal? function for each index that you're interested in- one input would be a constant of that number and the other input will be the index terminal of the for loop. Next, you can you a Compound Arithmetic found in the Boolean palette. The number of inputs of the Compound Arithmetic can be expanded to match the number of indices that you're interested in, and each input will be the output of an Equal? function. Finally, the output of this Compound Arithmetic will be in the input of the selector in a Case Structure where you will have a true and false case to toggle the Boolean. 

Josh Y.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 4
(5,265 Views)