Showing results for 
Search instead for 
Did you mean: 

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

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 Smiley Happy

0 Kudos
Message 1 of 3

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.

CLA // LabVIEW 2016 // BALUG // Unofficial Forum Rules and Guidelines
0 Kudos
Message 2 of 3
Accepted by topic author masoholic
05-19-2019 12:15 PM

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.


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.






0 Kudos
Message 3 of 3