LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to instantaneously divide values from an array's element with its initial value

I'm a newbie to LabVIEW and i'm trying to divide all succeeding values from all elements of a 4 element array with its initial value:

 

For example:

 

Array Element #1 = (2, 4, 6, 8, 10) divide by its initial element value of 2

Array Element #2 = (3, 6, 9, 12, 15) divide by its initial element value of 3

Array Element #3 = (4, 8, 12, 16, 20) divide by its initial element value of 4

Array Element #4 = (5, 10, 15, 20, 25) divide by its initial element value of 5

Resulting Array Element #1 = (1, 2, 3, 4, 5)

Resulting Array Element #2 = (1, 2, 3, 4, 5)

Resulting Array Element #3 = (1, 2, 3, 4, 5)

Resulting Array Element #4 = (1, 2, 3, 4, 5)

 

Thanks in advance!

0 Kudos
Message 1 of 7
(5,632 Views)

Your question is not quite clear.  You specify an array of numbers as element#1.  Is your array a 2D array?  Or maybe you are wanting to produce an output for each time the array elements change?  You can store the initial array element into a variable or another array.  Then divide the new element by the one you just stored.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 7
(5,625 Views)

Index the 2D array to extract the first column. Use an auto-indexing for-loop to divide each row by the 1D array (column zero) that you just extracted.

 

See attached (LV 8.6)

 

 
Message Edited by Phillip Brooks on 03-29-2010 01:25 PM
0 Kudos
Message 3 of 7
(5,616 Views)

I would do it like this.

 

Example.png

Tim
GHSP
0 Kudos
Message 4 of 7
(5,611 Views)
Example_VI.png
--
Tim Elsey
Certified LabVIEW Architect
Message 5 of 7
(5,610 Views)

sorry i wasn't clear with my question.  I do have a 1D array that contains 4 elements.  What I was trying to say in my previous post is how can I divide all succeeding iterations by the value of the first iteration (for all elements of the array)?

 

When I said

 

Array Element #1 = (2, 4, 6, 8 10) , i meant this as the value of the first 5 iterations having 2 as the resulting value of the first iteration. and I need to do the same operation for all 4 elements of my array.

 

I hope this helps!

0 Kudos
Message 6 of 7
(5,608 Views)

The trick is the save the first value.  Do this with a shift register in your loop.  When i=0, write the value to the shift register, when i not 0, divide by the shift register value.  See the snipit below.  Duplicate for every element, or convert it by adding more shift registers for all your elements.

 

ArrayDivide.png

- tbob

Inventor of the WORM Global
0 Kudos
Message 7 of 7
(5,562 Views)