LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I subtract each element in the same array?

I have an array. I want to subtract the first element from the second element in the same array, and from the third to the second, and so on. (eg. 1-0, 2-1, 3-2.....)
does anyone have any technique to solve this problem? This is my second week learning labVIEW.
Thank you very much.

Regards,

Sonny
son09@yahoo.com
0 Kudos
Message 1 of 3
(5,380 Views)
The easiest way is to rotate the array using the "Rotate 1-D Array" function. Rotate it by 1 ("N" input = 1). Subtract the original array and the rotated array using the "subtract" function (the subtract function will change to allow you to opperate on arrays!). Now use the "Delete From Array" function, wiring zero (0) into the index input.

-Jim
Message 2 of 3
(5,380 Views)
Sonny,
Consider a For loop, with 2 Index Array VIs. 1 index is wired to the iteration terminal and the other index is wired to the same iteration terminal incremented by 1. Then you will have the array element for Index i and index i+1. Now, subtract the 2 elements, send out to an array and you have an array with the subtracted values of i and i+1.

I've attached a VI to demonstrate.
Good Luck, Doug
Message 3 of 3
(5,380 Views)