LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to make reapeating random array to a series array in labview

Hi all,

Can anayone please help me on this , I have a random array and reapeating number, and i want the output must be in series, like 1,2,3 etc , but  non reapeating.. just like below. thanks

 

array series.png



Thank you & Best regards
syrpimp

=======================================================
“You must continue to gain expertise, but avoid thinking like an expert." -Denis Waitley
0 Kudos
Message 1 of 6
(1,976 Views)

Hi syrpimp,

 

this is a very nice exercise to learn LabVIEW.

 

You can solve this with several ways. And you may start with sorting your array and looking for unique values…

Best regards,
GerdW


using LV2016/2019/2020 on Win8.1/10+cRIO
0 Kudos
Message 2 of 6
(1,972 Views)

 I just did to sort on those array using Sort 1D  Array, but how to  find for unique value? what should i use ? thanks



Thank you & Best regards
syrpimp

=======================================================
“You must continue to gain expertise, but avoid thinking like an expert." -Denis Waitley
0 Kudos
Message 3 of 6
(1,968 Views)

Hi syrpimp,

 

to find unique elements you usually step over your array to copy elements from one array to a second one. And you only copy elements not present in the second array…

 

FOR each element in array1
  IF element not present in array2
    add element to array2
  ENDIF
NEXT

 

 

Best regards,
GerdW


using LV2016/2019/2020 on Win8.1/10+cRIO
Message 4 of 6
(1,956 Views)

This is where conditional indexing tunnels and feedback nodes come in handy.

 

Since you have the array sorted, all you have to do is check to see if the current element matches the previous.  Use a Feedback Node to hold the previous value.  Then use a conditional indexing output tunnel on your value.  If not equal to previous value, set the condition to TRUE.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 6
(1,930 Views)

There's also lots of OpenG functions that can help you do all this.  Of course for a learning exercise you should probably figure out how to do it on your own.  In the end a custom solution will probably use less memory, and less execution time then using OpenG stuff too.  

 

OpenG knows nothing about the data you are passing it.  For instance if the data is already sorted you can use some optomizations in array functions.  OpenG has to assume that an array is not sorted, and so will usually take longer performing operations that might not be needed.

Message 6 of 6
(1,918 Views)