10-16-2017 08:11 AM
I would like to implement a for loop into my design where I only use odd numbers between 1-49. However, I am unable to do so as the index in for loop is set to only increment by one. Are there any smart solutions to this?
Thanks.
10-16-2017 08:15 AM - edited 10-16-2017 08:17 AM
Hi salasjad,
Are there any smart solutions to this?
Well, is using simple math considered as "smart"?
What about a simple equation like "number := i*2+1" to calculate your odd numbers?
What about using a shift register initialized to 1 and getting incremented by 2 each iteration?
where I only use odd numbers between 1-49.
Based on this requirement ("using only odd numbers") you could even use a case structure inside the loop to only do some work when i is odd… 😄
10-16-2017 08:18 AM
I would not call it a "smart solution", but... take the index, multiply by two and add one.
10-16-2017 08:53 AM
you could even think about using something like the "Ramp Pattern.vi" function to create an array of odd numbers outside the loop.
10-16-2017 11:31 AM