08-29-2011 03:37 PM
Could I get some advise on how to build this...I need to take a number and add a constant to it, then take the new number and add the constant, so on for 401 iterations feeding to a 1D array. I know this must be simple, but I can't figure it out. Thanks.
Solved! Go to Solution.
08-29-2011 03:46 PM - edited 08-29-2011 03:54 PM
:dunno
Code attached.
If you want the input as element zero of the array, remove the [+1] between [i] and the multiply.
08-29-2011 03:46 PM
Try a for loop with a shift register. Autoindex the outupt to get the array.
Lynn
08-29-2011 04:03 PM
Ohhh, nice let me try that tonight...Thanks!
08-29-2011 04:18 PM - edited 08-29-2011 04:19 PM
@frakintosh wrote:
Could I get some advise on how to build this...I need to take a number and add a constant to it, then take the new number and add the constant, so on for 401 iterations feeding to a 1D array. I know this must be simple, but I can't figure it out. Thanks.
I need to take a number
(drop a control onto the front panel and call it "Input")
and add a constant to it
(drop an "Add" there, wire input to first terminal)
then take the new number and add the constant
(Loop of some sort, iteration multiplied by the constant)
so on for 401 iterations
(wrap a for-loop around the whole thing, new control into the number-of-iterations terminal)
feeding to a 1D array
(For-loops can easily auto-index, just bring the output of the add to the edge of the for-loop)
I know this must be simple
(This is why graphical programming rocks!)
08-30-2011 08:30 PM
PERFECT...thanks for the quick reply and help SnowMule!
08-30-2011 08:52 PM - edited 08-30-2011 08:54 PM
SnowMule wrote:Code attached.
The terminal of the control labeled "constant" belongs before the FOR loop. There is no need to re-read it at every iteration, because it should probably not change while the loop is executing (if it would change, the results would be unpredictable).
Here's what I usually do. (if you like the +1 variation in snowmule's code, simply tap the wire after the "add" instead of before as shown)
There is also "ramp pattern", of course.... 😉
08-31-2011 10:39 AM
@altenbach wrote:The terminal of the control labeled "constant" belongs before the FOR loop. There is no need to re-read it at every iteration, because it should probably not change while the loop is executing (if it would change, the results would be unpredictable).
Yea; it's not "perfect" code, did spot some things like that to improve performance.
Didn't know about that ramp function... good to know.