From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Finding value gaps in array

Hi there,

 

I have an sorted array, in which some elements have increasing values, I want to find gaps between values in that array and I want to create new sub array according to gaps between values.

 

For example I have this array:

[104,105,106,107,108,154,155,156,157,175,176,180,191,192,193]

 

Which I want to have is those arrays:

[104,105,106,107,108]

[154,155,156,157]

[175,176]

[180]

[191,192,193]

 

is there any way to do that?

 

Thanks.

0 Kudos
Message 1 of 6
(2,991 Views)

Hi kahlenberg,

 

is there any way to do that?

Yes, there is.

 

Spoiler
You could search for those "gaps" in your array and remember their index values. Then you get subarrays from index1 to index2…
Best regards,
GerdW


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

Thanks for quick reply. Yes, my first intention was also so, but I wonder If there is a labview function doing this. It seems there is not 🙂

0 Kudos
Message 3 of 6
(2,976 Views)

Hi kahlenberg,

 

I wonder If there is a labview function doing this. It seems there is not

There is a full palette of array functions. There are comparison functions. There are math functions.

So there are a lot of LabVIEW functions allowing you to do what you want to do!

You know this process is called PROGRAMMING!?

 

To give a hint:

check.png

(This is made with LV2009, with more recent versions you can use conditional tunnels…)

Best regards,
GerdW


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

Hi GerdW,



...You know this process is called PROGRAMMING!?

 


Why is there Search1DArray function then, if it can be also programmed by programmer?

 

I know what Programming is, thanks for teaching me.

I just would like to know whether there is such a function like Search1Darray or not.

If yes, I don't want to invent the wheel again.  If not, I can do it myself.

BTW, Thanks for code.

 

Regards.

kahlenberg.

 

0 Kudos
Message 5 of 6
(2,941 Views)

Hi kahlenberg,

 

 

you were asking for a function, that should search for some "gaps" and split your array into smaller array parts. No, such a function does NOT exist.

But you can use several other functions to reach your goal. That was what I was teaching you…

 

And yes, you can even use Search1DArray for your task…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 6
(2,938 Views)