LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Find array in 1D array

Solved!
Go to solution

@altenbach wrote:

@Valentin87 wrote:

Below I attach picture with example what need to realize


Flatten both to string and search string.


Nice first thought but will we not run into complications since there is not eight bits in the match pattern AND the match could happen across characters?

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 11 of 17
(1,692 Views)

@Ben wrote:

Nice first thought but will we not run into complications since there is not eight bits in the match pattern AND the match could happen across characters?

No, unless you use 4.x mode, boolean arrays are stored one byte/element.

 

(see also the image I have now attached to the earlier post)

 

(Of course it also assumes that the boolean arrays are "normalized" for lack of a better word, else all bets are off. :D)

0 Kudos
Message 12 of 17
(1,688 Views)

The solution in #9 will work if you have an exact match.

 

If there is a chance the match is not exact, this will work:

Boolean as Numbers.png

0 Kudos
Message 13 of 17
(1,678 Views)

@Ben wrote:

 

A basic suggestion is to search for the first element of your "target array" and only when you find a match on the first, proceed to check the residual data for a match.

Ben


Here's how this could look like. 😄

 


 This now also works for all other array datatypes, but will only find exact matches, of course, so be careful with floating point comparisons. It can be easily modified to find all matches if there are more than one.

0 Kudos
Message 14 of 17
(1,670 Views)
Solution
Accepted by Valentin87

@altenbach wrote:

It can be easily modified to find all matches if there are more than one.

Here's how that could look like. The size of the output array is the number of matches. If it is empty, no matches were found.

 

Message 15 of 17
(1,660 Views)

@altenbach wrote:

@altenbach wrote:

It can be easily modified to find all matches if there are more than one.

Here's how that could look like. The size of the output array is the number of matches. If it is empty, no matches were found.

 


Could you attach this as VI saved in LV2011?

0 Kudos
Message 16 of 17
(1,643 Views)

LAbVIEW 2011 does not have conditional tunnels, so you would need to do some simple workarounds. You should be able to implement the earlier version that only returns the first match.

 

The code is quite trivial. What parts prevent you from creating the code from scratch? Have you done some tutorials?

0 Kudos
Message 17 of 17
(1,640 Views)