LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

compare 2 1D arrays and return indices of the same elements

Solved!
Go to solution

Hello NI community,

I'm pretty new to LabView,  and facing some difficulties in comparing two 1D arrays.

The thing is: I've created an event, which split user's input string into an array. Then I need to compare it to other array called "alphabet" in order to get all the indexes of the same elements in "alphabet" array, so that i could use these indices to retrieve proper Morse code of each letter.

Can I get some tips on how to do such comparison of 2 arrays? 

Any help would be appreciated 🙂

0 Kudos
Message 1 of 3
(2,481 Views)

Depending on the format of your "string2", it may be easy to convert to an array using "spreadsheet string to array". You could then create a variant lookup table for your morse code to alphabet conversion.

0 Kudos
Message 2 of 3
(2,460 Views)
Solution
Accepted by topic author masoholic

Hey Masoholic,

 

I would go for a nested for loop for the search and substitution. On every element of the array you check against every element of the alphabet array. When it matches the morse at the corresponding index is being called.

I have put together a simple code, feel free to use it.

Screenshot_1.png

ALSO: alvays put the event source into the event case to ensure proper mechanical action. Also stop case was added so your application now can be stopped.

 

 

Cheers!

 

 

0 Kudos
Message 3 of 3
(2,414 Views)