LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Search for a pattern in array

Solved!
Go to solution

I have an array of U8 values and a string array of the pattern I want to search for:

RFeng_0-1589995672016.png

 

The string array has 5 values and the U8 array many.  I want to compare the 5 string array values against the first 5 Array u8 values (starting at index 0) if not found I want to compare the 5 string array values with 5 of the Array u8 values (starting at index 1) if not found then again compare the next 5 values of the Array u8 (index 2) etc........any help will be appreciated !

0 Kudos
Message 1 of 40
(3,240 Views)
Solution
Accepted by RFeng
I'd use a For loop and use Get Array Subset starting at i and going to i + length (smaller array), then use an Equal? set to Compare Aggregates (a right click option). Also, you'll need to convert either the string array to a U8 array or the U8 array to a string array before starting this. I'd recommend the former as it's a smaller conversion and will take care of things like someone typing 1.0 in your string array instead of 1.
Message 2 of 40
(3,225 Views)

Thank You! Didn't know about Compare Aggregates.  

0 Kudos
Message 3 of 40
(3,212 Views)

Hello, 

I'm trying to detect in 2-D Array the pattern of six followings 1 ( "111111").

If the pattern is detected in first column then my code should copy two columns ( 2 x 18) to the new subarray ( for further processing)  and start the searching process again.

I'm trying to compare two arrays but it seems that something doesn't work.

How to restart the searching process: in next portion of data will be searched next pattern of "111111" 

All new subarrays should be pushed out of loop for other calculations.

Tomasz_Poland_0-1707477676614.png

 

Tomasz_Poland_1-1707477754318.png

Thank You 

Tom

 

0 Kudos
Message 4 of 40
(1,338 Views)

Hi Altenbach,

I'm a beginer with labview. 

I'm trying to create the code as on Your post but it seems that I'm still missing some settings.

Could You take a look on my code and give me some hints.

In the meantime I'm trying to extend this code for 2-D Array: if subarray is detected in first column then starting from the index of first the following 18 rows is taken to subarray.

Could You support me little bit with this?

Best regards

Tomasz

 

Labview 2020 / 32 bits

0 Kudos
Message 5 of 40
(1,306 Views)

Here is a slight Modification of your code.

 

I did not touch the looplength. It is just an Idea.

Hope it helps.

Gernot Hanel
IONICON Analytik Gesellschaft m.b.H.
0 Kudos
Message 6 of 40
(1,280 Views)

Hi Nottilie,

Could You compile attachment to LV version 2020 32 bit or insert screnshot, please?

I have LV 2020  and it results an error:

Tomasz_Poland_0-1707758793989.png

Thank You

Tomasz

0 Kudos
Message 7 of 40
(1,268 Views)

@Tom_wolf wrote:

I'm trying to create the code as on Your post but it seems that I'm still missing some settings.

Labview 2020 / 32 bits


I have not posted in this thread and I am not sure why you are asking me specifically. If you were trying to modify one of my programs, please give a link to the original discussion.

 

It is also not a good idea to append to a thread that is already marked as solved. The original discussion talks about an U8 array, but you have an I32 array, which is a quite different problem.

 

I think we should stick with solving the 2D array problem. Do you just want to find the first match or all matches? How should the output look like? Why is the "Pattern a 2D array if we are only interested in a 1D pattern? All your control terminals belong before the loop, of course.

 

When attaching code it also really helps if the controls contain typical default values. Empty arrays are probably not typical.

 

 

0 Kudos
Message 8 of 40
(1,237 Views)

@nottilie wrote:

Here is a slight Modification of your code..


(code in LabVIEW 2024 that most don't have. Make sure to use "save for previous" before attaching)

 

It is a really (really!) bad idea to attach modified code with the same filename as something that has been posted earlier. You need to give it a new name!

0 Kudos
Message 9 of 40
(1,235 Views)

See if this can give you some ideas....

 

 

altenbach_0-1707789414709.png

 

 

Message 10 of 40
(1,225 Views)