NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
bmemq
Posts: 11
0 Kudos

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 ?

Member
JoshY
Posts: 79
0 Kudos

Re: how to pick up indices for a for loop

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
Member
bmemq
Posts: 11
0 Kudos

Re: how to pick up indices for a for loop

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?

Member
JoshY
Posts: 79
0 Kudos

Re: how to pick up indices for a for loop

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
By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page