LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you subtract different values for specific array elements?

Solved!
Go to solution

Hi LabVIEW Community,

 

I am new to LabVIEW and Im working on my first application. One of my challenges that I am having problems solving is how to  subtract specific values from specific elements in an array.

 

My aplication is to measure the distance between a sensor and a magnet, however the initial distance for each sensor  to magnet is different. I have converted the voltage to a distance using the Math Node for each element and now need to  correct these values by subtracting their individual initial value.

 

The source is a 1D array of DBL64  consisting of 32 elements and each of these values needs to have a different value subtracted.

 

eg:

Element 1 - 5.557

element 2  - 2,34

element 3 - 7,654  and so on

 

I have tried to seperate (index the array) and subtract the values from each element and then combine them again. This has not been effetive. I need to write these values to an .txt file and also use them in another calculation.

 

I have attached my attemted sub VI.

 

Any advise would be really apprecieated.

 

 

 

 

0 Kudos
Message 1 of 8
(3,103 Views)

Could you please upload your VI again for LV12?

thanks.


0 Kudos
Message 2 of 8
(3,099 Views)

Hello ectoxmussel,

 

The numeric operator primitives are polymorphic and can operate on your arrays element-by-element if you provide two arrays containing the operands.

 

It's simple once you know that it works, but if you don't read the help for the primitives it can be overlooked pretty easily - I've definitely been surprised in the past by things like this that "just work"!

 

Untitled.jpg

 

Hope that helps! 

Tom L.
0 Kudos
Message 3 of 8
(3,098 Views)

Thanks for the quick reply,

 

Here is the Sub VI in LV12

0 Kudos
Message 4 of 8
(3,086 Views)
Solution
Accepted by topic author ecotoxmussel

You don't need to overthink it. There's a really simple method. Generate an array that contains all your offsets you want.  Then subtract it off.

 

It's the same VI with this change:

 

Certified-LabVIEW-Architect_rgb.jpgCertified_TestStand_Architect_rgb.jpg


"I won't be wronged. I won't be insulted. I won't be laid a-hand on. I don't do these things to other people, and I require the same from them." John Bernard Books

Message 5 of 8
(3,068 Views)

Hi Tom L.

 

Thanks for your quick reply. I will have to look at it again when I go back to uni tomorrow.

 

Cheers,

 

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

Hi bsvare

 

Thank you for your help and advise. As an ecology student there seems to be no simple methods:).
I will run the modified VI tomorrow when I return to uni.

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

Thank you for your help. My program is now running and I am collecting data. It was an easy solution but it just never came to mind.

 

Cheers once again for your time bsvare!

 

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