LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sum of squares of differences of two arrays

Hi

I would like to calculate the sum of the squares of differences of two arrays.

Is that a built in function? I can write my own VI, but since I have to do 1000s of these in an analysis, a VI that is built in and optimized would be nice.
0 Kudos
Message 1 of 4
(3,988 Views)
I don't remember seeing this in LabVIEW, but a tip for you would be to do this as an array function. That is, build the function without wiring the input, then, wire the arrays as inputs. The functions work whether the inputs are elements or arrays, and the result will be an array of the difference. To get the sum, just use the Add Array Elements function.
0 Kudos
Message 2 of 4
(3,988 Views)
WLS;

I am sure this can be done pretty easy with LabVIEW's functions.

I take it a shot. If I interpreted your problem correctly, the attached VI do it. Is the result a single number? Depending on your application or conditions, you may want to add error checking.

Regards;
Enrique
www.vartortech.com
0 Kudos
Message 3 of 4
(3,988 Views)
> I would like to calculate the sum of the squares of differences of two
> arrays.
>


You might look around in the statistics and probability functions to see
what is closest to what you are looking for.


If you need to make your own. Wire the two arrays to a subtraction
node. No loop needed and you now have an array of differences between
the elements of the arrays. Now you have an array of values and you
want the sum of squares. In case you really want the RMS, there is an
analysis VI for that, but if you really want the squared value, then you
can split the wire and wire to a multiplier node. That will square each
element and produce an array of squares of differences. Finally, you
can wire to the Sum node. If I understand what you original
ly wanted,
these three nodes will do it.

If you are using it in quite a few places, select the three nodes and
under Edit choose Make subVI. Fill in a description, an icon, and you
are done.

Greg McKaskle
0 Kudos
Message 4 of 4
(3,988 Views)