LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Remove elements from an array

Dear altenbach,

Can you post or send me the actual LabView file for your solution regarding removing elements from an array? I'm trying to use your code for a 2D array but I'm having some trouble getting it to work.

Thanks
0 Kudos
Message 11 of 16
(4,238 Views)
None of this can work with a 2D array because there is no general solution.

For example what should happen if only element(1,1) contains a zero. You cannot shorten row 1 or column 1, because all rows and columns need to be the same size. What if you have 3 zeroes in a 4x4 2D array, you cannot have a 2D array with 13 elements.

You need to reformulate your problem so it is mathematically possible, e.g. you could remove all rows or all columns that contain one or more zeroes, etc.
0 Kudos
Message 12 of 16
(4,193 Views)
Within a 2D array I need to remove any row which has a zero in a specified column. I've been able to adapt your first solution to this case but, as you suggest, it slows down for large number of array elements - it's especially slow for a 2D array. I've had some trouble getting your second solution to work. If you could post the LV code I can make sure I'm using the correct built-in LV functions.

My application in general is to extract rows from a 2D array which have elements containing a certain value. For example, if a row in my 2D array is: (10,502,1) then I would like to extract that row since the second element is in the range 500 to 515. I look at each row in the 2D array and use a case statement to separate out the rows I want to extract. The problem is that LV leaves (0,0,0) in the input array for every row that is extracted - I can't allow these values to remain. I need to extract those rows that have only a zero in the 2nd column.

I've tried to build each array from within my case statement but that is very slow for a 20,000 by 3 array (takes 20 seconds). Using local variables within the case is also very slow. As is suggested in this thread, the problem must be with shifting the array data many times with the array functions. Does anyone know a fast way to remove certain data from an array without leaving behind zeros in the input array?
0 Kudos
Message 13 of 16
(3,883 Views)
Here is a quick adaptation of my earlier code for your 2D problem. (LabVIEW 7.1). Enjoy! 🙂

(I also attached the earlier 1D VI for comparison)

Message Edited by altenbach on 04-11-2005 06:00 PM

Download All
Message 14 of 16
(3,881 Views)
OK, some benchmarking for the 2D Solutions.

You should ONLY use the bottom code, it is much faster.

Some timing examples with 5% zeroes (1GHz PIII laptop) for the optimized code:

size = 2000 x 3, time = 1ms (upper code=200ms)
size = 20000 x 3, time = 14ms (upper code=22seconds)
size = 200000 x 3, time = 138ms (upper code not tested)

On a fast computer, you should get well below 10ms for your 20000x3 array. Pretty amazing! 🙂
0 Kudos
Message 15 of 16
(3,872 Views)

Can any one provide me the programs written "RemoveZeros_1D.vi" having version Labview 7.

 

With Regards

Abhijit Das

IITG, INDIA

0 Kudos
Message 16 of 16
(3,099 Views)