LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
ouadji

Search for a different element

Status: Declined

Any idea that has received less than 2 kudos within 2 years after posting will be automatically declined.

a possible improvement for the "search 1D function"

 

The current function searches for an element identical to the input element.
It would be useful to be able to do the opposite :

 


            Search 1D Array : be able to search a different element

 


a new function or ...

the current function with an option to select : "the same element", or "a different element".

 

and why not (It would be also useful) an additional output with this different element.

 

 

SR1.png

14 Comments
crossrulz
Knight of NI

I would run into that situation so little of my time.  And it doesn't take long to make you own VI with a FOR loop if that is really want you wanted.  Sorry, no Kudos from me.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
ouadji
Trusted Enthusiast

@ crossrulz :

 

yes, you are right, it's "always possible" to make it oneself.
But this is also valid for the current function ... and many others!

Yet, this would be so easy to do it. Just compare with "equal" or "different", rather than only "equal".
One or two additional lines of code would be enough to make valid this function in both cases.

It would be a pity to go without something so easy to improve.

X.
Trusted Enthusiast
Trusted Enthusiast

I probably would use this rather than a loop:

 

ScreenHunter_001.jpg

 

But this being said, I think that the comment that this is a rarely used search occurence is probably why you won't get much traction for this "logical" suggestion.

You could argue the same for all kinds of comparison on arrays of numerics, BTW.

For instance, search whether an element is larger or smaller than a particular value (would also be applicable to array of clusters), or within a range, as a variant of the diagram above:

 

ScreenHunter_002.jpg

 

ScreenHunter_003.jpg

 

I had fun with the last diagram. Can you guess what results it returns?

 

ouadji
Trusted Enthusiast

 

I had fun with the last diagram.

 

Can you guess what results it returns?  Smiley Happy

 

include upper limit ? (y/n)

include lower limit ? (y/n)

ouadji
Trusted Enthusiast

sorry, I have to leave internet. i will be back later.

ouadji
Trusted Enthusiast

2 2 array X [0] [4 (array upper[0])   =  false

2 ]  2 array X [1] [ 5 (array upper[1])   =  false

 

Search 1D Array (False,False) for "True" ... result = -1

 

 

 

 

 

 

X.
Trusted Enthusiast
Trusted Enthusiast

Yes, I was sort of suprised that after having wired a single scalar to the lower limit, the created constant for the upper one turned out to be an array.

The "In range?" array in the example above has a the dimension of the "Upper Limit" array.

What I was aiming for was this:

 

ScreenHunter_001.jpg

 

which returns the expected index (4).

 

I still do not get the multiple array bounds usefulness:

 

ScreenHunter_002.jpg

 

returns -1 as well. but the important message is that the Boolean array result is of size 1, i.e. the minimum size of both the upper and lower limit arrays.

 

Anyhow, my point is that the general (simple) solution to your request is in fact quite powerful.

And probably doesn't justify rewriting the primitive...

ouadji
Trusted Enthusiast

@ X

 

but the important message is that the Boolean array result is of size 1,

i.e. the minimum size of both the upper and lower limit

 

1 ?   i don't understand ... my result below (LV2013)

 

SR1.png

X.
Trusted Enthusiast
Trusted Enthusiast

Yes, because you have only one array in this example. If you replace the lower scalar by a single element array, it will return a single element Boolean array.

I am sure there is a clever use case for this, I just can't think of one.

ouadji
Trusted Enthusiast

ok, understood !

 

thank you X for your explanation and time spent.

 

pouce_levé.gif