02-12-2015 03:50 AM
Hi all,
I have a scalar value and a 1d array. I want to compare scalar with each elements of 1d array and extract the values which are higher than the scalar into a separate 1d array.
Can anybody suggest me how to go about it.
Solved! Go to Solution.
02-12-2015 04:01 AM
Hi, kamasani
Use for loop can do it.
u can see the attachment
Patrick
02-12-2015 05:18 AM
Hi Patrick,
Thanks for your time,
I am using LV 2011, i am unable to open since the program is in LV 2014. Can you plz post a screen shot of the VI attached.
02-12-2015 05:42 AM
Hi kamasani,
ok, I convert vi to 2011.
02-12-2015 06:08 AM
Hi Patrick,
Thanks for your reply, i was expecting a different output. I figured it out myself after i had a look at your program. I have attahced the program with modification.
02-12-2015 01:30 PM
Kamasani,
You do not need the for loop. The attached VI shows how to get the same result without it.This takes advantage of the polymorphism of many numeric and boolean functions. In your original post you asked to extract the values above the threshold into a separate array. The code at the bottom of the VI attached shows how to get an array with only those elements (no zeros). Of course this no longer has information about where those elements were in the original array.
Lynn
02-12-2015 02:54 PM
Patrick0418 wrote:ok, I convert vi to 2011.
This does not solve the described problem, which is" "... I want to compare scalar with each elements of 1d array and extract the values which are higher than the scalar into a separate 1d array."
Typically, the output array is thus shorter. In your code, the output array remains the same size as the input.
Look at Lynn's solution (bottom of his diagram).