LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

search 1d array

Hi. I'm stuck to find 1d array. Previously I have successfully created for searching string array, for this time I try to find it in by numeric. I attach a picture for search string array code that I've done before.

SofeaNur_0-1672583694138.png

 

For the search numeric array, I try to do the same thing with search string array but now I'm stuck.

SofeaNur_2-1672583969056.png

I'm sorry if my question is silly but I hope you guys can give me a suggestion and I can learn a new things for this part 😄

 

0 Kudos
Message 1 of 3
(896 Views)

Hi SofeaNur,

 


@SofeaNur wrote:

Hi. I'm stuck to find 1d array. Previously I have successfully created for searching string array, for this time I try to find it in by numeric. I attach a picture for search string array code that I've done before.

 

For the search numeric array, I try to do the same thing with search string array but now I'm stuck.

 

I'm sorry if my question is silly but I hope you guys can give me a suggestion and I can learn a new things for this part 😄


From your images I guess you want to search the array for elements which contain your search item - atleast that's what your string search does.

Now you want to implement the same for U32 values: find U32 values that contain a certain digit/number (in their decimal notation)?

 

Then this will do the trick:

Please do some more basic LabVIEW learning! Learn about using autoindexing in loops, learn about those different tunnel modes available since ~10 years, learn…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 3
(885 Views)

Your blue code has no resemblance to your pink code, thus it will of course not work.

 

Creating an output array with all the same number seems a bit boring and redundant. More interesting would be the indices where the elements were found or even just the number of matches.

 

Here's what I would probably do. try it!

 

altenbach_0-1672591779662.png

 

(Be aware that if the datatype is DBL, thing might become more tricky because equal comparisons are dangerous.)

 

Note that your old string code does NOT find elements that match the search string, but all elements that contain the search string. For example if you search for "cde" and one of the array elements is "abcdefg", it will be a match. Not sure if you really want that. Maybe as a first step you should exactly define what you are searching for in the numeric version. For example if one number is 12345 and you search for 45, should that be a match or not? If yes, uses Gerd's code.

 

A few more comments to your attached code:

 

General:

  • it is offensive to forum members to attach a file named "Untitled 1.vi". Many others have done the same, so my browser renamed the VI as "Untitled 1(25).vi". If this were a subVI, the caller would probably call the wrong subVI and substitute "Untitled 1.vi" from an old unrelated posts, breaking everything! There is no real additional effort to give a VI a unique and descriptive file name.

Front panel:

  • Never show arrays that are scrolled to element 5 with the first few elements hidden. that's just confusing. If the arrays are larger than the container, show the scrollbar!
  • Give controls and indicators reasonable names. "array" and "numeric" are not reasonable.
  • While your input array seems to have some useful typical default values, the output array should have the desired output so we know what you are looking for and test. You can clear the indicator and manually enter the expected results, then make them default.

Diagram:

  • Wiring the size to N and indexing using [i] is exactly the same as autoindexing..
  • Appending to an empty array in a shift register is the same as autoindexing at the output.
  • Conditionally appending to an empty array is the same as conditional autoindexing.
  • etc.
0 Kudos
Message 3 of 3
(870 Views)