From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

getting one particular element value in an array satisfying a condition given in different array

Solved!
Go to solution

hello,

i am having problem in programming of extracting one value(particular element) from an array with a given condition which is dependent on the another array.

for example, lets say i have a set of data from -1v to 1v with their corresponding current . all these data voltage and current are in a two different array .

now if i want to get an element in current corresponding to which the element value in voltage array is zero.how do we find that?

i tried to put in a way as we do in c with two nested loop but here i am not able to do it here.please anyone help me out of it.atleast give a initial 2-3 steps what to do.

0 Kudos
Message 1 of 8
(2,165 Views)
Solution
Accepted by topic author jyot445

Search the voltage array to return the index of the match then use the index to select the item from the second array.  Simple! or am I misunderstanding your problem

 

Ken

0 Kudos
Message 2 of 8
(2,163 Views)
Solution
Accepted by topic author jyot445

Hi iyot,

 

use Interpolate1DArray:

check.png

(Or create an interpolation formula from your values…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 8
(2,159 Views)

but what if i am not getting the exact value of it say i want current when voltage is 2 V BUT IN DATA  its slightly greater than or less than it,then how to solve this

0 Kudos
Message 4 of 8
(2,148 Views)
Solution
Accepted by topic author jyot445

Hi iyot,

 

what if i am not getting the exact value of it say i want current when voltage is 2 V BUT IN DATA  its slightly greater than or less than it,then how to solve this

Use the suggestion from my previous post!

It will interpolate (using the Interpolate1DArray function) between the points defined in those voltage/current arrays. Any outliers are limited to min/max of your point array(s).

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 8
(2,139 Views)

thanks a lot 🙂

 

0 Kudos
Message 6 of 8
(2,107 Views)

well,its not giving the value as required.in short the way you suggested is not working

0 Kudos
Message 7 of 8
(2,104 Views)

What Gerd told will work if written correctly.

 

If your code is not working then there is trouble with your code. Unfortunatly my eye are getting old and I can not quite make out what you have coded from where I am sitting.

 

Show us the code.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 8 of 8
(2,097 Views)