LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

delete array elements periodically

Hi,

 

I'am trying to rezise  a 2D array (of strings), by keeping only one line every n lines.

I guess I should use the "delete from array function", but after several trial, I can only delete some consecutive portions, not periodically...

 

Any tips / example for such function?

 

Thanks in advance

 

antoine

0 Kudos
Message 1 of 5
(2,932 Views)

 

If you use "delete from array" you need to start with the highest index, because each deletion operation will shift the remaining lines down, changing their index. However, this is very inefficient.

 

There have been been many example posted how to do this operation "in place". Why don't you show us your best trial VI containing some typical default sample data?

0 Kudos
Message 2 of 5
(2,927 Views)

Ahh... I wonder if you have stumbled onto a common issue when manipulating arrays:

 

If you delete a row from a 2D array, you are actually resizing it.  So the index positions of all subsequent rows get reduced by 1.

 

Anyway, that may not be your issue.  We'd have to look at your code. 

 

I would probably just index the array instead of using the delete function (see below).  But this method will probably be SLOW if you have a big array.  Try it out:

 

snippet.png

 

 

http://www.medicollector.com
0 Kudos
Message 3 of 5
(2,924 Views)

Here's a quick in-place solution which will be orders of magnitude faster that the one using "build array" for large arrays.

You might need to tweak it a little bit, depending on if you want to keep the first row or not.  (e.g. try adding a +1 between the iteration terminal and Q&R)

 

(Attached VI is in LAbVIEW 8.2)

 

Download All
Message 4 of 5
(2,918 Views)

Hi, 

 

Thanks a lot to both of you.

I tried both solutions, and both works  fine, I'll go for altenbach's one as my array size will be contiously increasing, so faster is better.

 

I understand that this question was discussed already, sorry for that,  but I made a lot of unsuccessfull researches prior sending the post... I think I was missing the good keywords : decimate

 

On .vi standpoint, I was not that far, but I was missing the function "quotient and remainder" (yes, newbie...)

 

Thanks again for your help.

 

regards

 

antoine

 

 

 

 

0 Kudos
Message 5 of 5
(2,890 Views)