03-29-2010 12:07 PM
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!
03-29-2010 12:15 PM
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.
03-29-2010 12:23 PM - edited 03-29-2010 12:25 PM
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)
03-29-2010 12:25 PM
I would do it like this.
03-29-2010 12:26 PM
03-29-2010 12:29 PM
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!
03-29-2010 02:42 PM
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.