LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Iteration question

Solved!
Go to solution

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. 

0 Kudos
Message 1 of 8
(3,198 Views)
Solution
Accepted by topic author frakintosh

:dunno

 

 sausagepanel.PNG

 

Code attached.

 

If you want the input as element zero of the array, remove the [+1] between [i] and the multiply.

Download All
0 Kudos
Message 2 of 8
(3,192 Views)

Try a for loop with a shift register.  Autoindex the outupt to get the array.

 

Lynn

0 Kudos
Message 3 of 8
(3,191 Views)

Ohhh, nice let me try that tonight...Thanks!

0 Kudos
Message 4 of 8
(3,178 Views)

@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!)

0 Kudos
Message 5 of 8
(3,171 Views)

PERFECT...thanks for the quick reply and help SnowMule!

0 Kudos
Message 6 of 8
(3,135 Views)

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.... 😉

0 Kudos
Message 7 of 8
(3,129 Views)

@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. 

0 Kudos
Message 8 of 8
(3,111 Views)