LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

In a 2-D array how to delete a empty array??

Hii

 i am having one 2d array in that some of the rows are empty i want to delete it how to do it??
0 Kudos
Message 1 of 7
(4,316 Views)

Delete From Array.

What you don't define is 'empty'. The data in a row has to be something (empty string, all zeroes, whatever) and if your problem is identifying those rows, you need to provide some information on the type of array (numberic, string, Boolean), and what the data is.

Message 2 of 7
(4,312 Views)

This is a solution for a numeric 2D-array.

 

However, this is a slow example and if you use both positive and negative values in you array, this could not always work properly.

 

 



Message Edited by Heinen on 03-10-2008 09:05 AM
--------------------------------
The Enrichment Center is required to remind you that you will be baked, and then there will be cake.

0 Kudos
Message 3 of 7
(4,292 Views)

One should not mistake zeros with emptiness.

Zeros (0) are values..  Empty is ... well... nothing..

So as Dennis mentionned, the term "empty" needs to be defined, because there is no need to remove "empty" entries because they are not there.  😉

Message 4 of 7
(4,286 Views)
No, a 2D array cannot have empty rows, even not empty values. If the position is in the array-size it will be
set to 0 if no value is given to it.
 
 
--------------------------------
The Enrichment Center is required to remind you that you will be baked, and then there will be cake.

0 Kudos
Message 5 of 7
(4,281 Views)

Heinen,

You are assuming that it is an array of numerics.  As Dennis mentionned, the array type was not mentionned.  It could be strings, clusters, references, etc., as long as it is of the same type.

In the case of a numeric array, if the 2D array was padded, then the row was not empty 😉

Let's find out the rest of the story..  Karthi??

0 Kudos
Message 6 of 7
(4,267 Views)


Heinen wrote:

This is a solution for a numeric 2D-array.

However, this is a slow example and if you use both positive and negative values in you array, this could not always work properly.


Well, yes, this is highly flawed, because it will drop all rows without a DC component. I often work with first derivative spectra that are offset corrected so the sum is zero by definition. They would all get dropped by your code.
 
The correct way to do the comparsion would be to wire an "=0" to the 1D array followed by an "AND array elements". If you get a TRUE, all elements are zero. 😉

 

I think we should not dwell too much on the definition of "empty", because the bulk of the code means deleting a row or column that matches a certain pattern from a 2D array, defining and detecting the pattern is probably trivial once we kow what the poster wants.
 
As Dennis said, there is "delete from array". Check the online help for proper use. (If you have a huge array and need to delete many rows or columns, there are more efficient ways to do it by doing all operations "in place". and trimming the size at the end).
0 Kudos
Message 7 of 7
(4,241 Views)