LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

deleteing element by element in 2D array

Is there away to delete element by element in 2D array without changing the dimensions to 1D array. I want to select the first 20 element reading across the rows. For example, If I have 2D array with 6 element in each raw. I want to select the first three rows and 2 elements from the four raw.

 

Regards

Hussain

0 Kudos
Message 1 of 8
(3,418 Views)

Arrays need to be ... rectangular (for lack of a better description).  You can't have one row with 4 elements and a second row with 10.  If you try to do this, LabVIEW will automatically populate the blank rows with a null of your array type.

0 Kudos
Message 2 of 8
(3,412 Views)

Each row must have the same number of elements in it.  Same for columns.  So you can delete whole rows and/or whole columns, but not individual elements.  Just use Delete From Array to do that.


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
0 Kudos
Message 3 of 8
(3,411 Views)

The best way to do this is with an array of clusters of 1-D arrays.  See a similar question I posted last year for more details:  http://forums.ni.com/t5/LabVIEW/Uneven-2-D-Array/td-p/2497412

 

To summarize:

 

Only real solution is an array of clusters each containing another array.

 

2013-07-19 13_46_03-Untitled 1 Front Panel _.png

 

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If someone helped you out, please select their post as the solution and/or give them Kudos!
0 Kudos
Message 4 of 8
(3,402 Views)

Maybe I completely misunderstand what the OP tried to say / do, but you can accomplish it without using clusters.  Comments from others are correct, you cannot resize the 2D array by deleting elements within a given row..  However, maybe you want to achieve what is described below.

 

Do keep in mind that if you attempt this with a numeric array, you may want to use 0 or 'NaN' as your deleted value.

 

See code below which should be self-explanatory.  There are probably better improvements of the example, but the purpose was simply to show how it can be done.

 

Array 1 shows the original 2D array and it's values.

 

Array 2 shows how you can "delete" or replace its element with a "deleted" value.

 

Array 3 shows how you can "delete" multiple elements (replace multiple elements with a "deleted" value).

 

 

 

Download All
Message 5 of 8
(3,386 Views)

I thank you guys for help and suggestions. I think I need to break the 2D array and delete  the elements and build it again or convert to string and do the same. I was hoping for one icon solution but it seems there is no such option.

Thanks

0 Kudos
Message 6 of 8
(3,330 Views)

It really depends what you are looking for.  Can you give an example of what you want?


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
0 Kudos
Message 7 of 8
(3,316 Views)

@Husain111 wrote:

I think I need to break the 2D array and delete  the elements and build it again or convert to string and do the same.


I don't understand at all what you are trying to say here. What is "break"? This is not a technical term commonly used with 2D arrays.


@Husain111 wrote:

I was hoping for one icon solution but it seems there is no such option.


Of course there is, just create your own subVI. 😄

0 Kudos
Message 8 of 8
(3,307 Views)