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: 

2D array

Hello,

 

Please help,

 

I have a 2D array and I want to add values to the bottom of a single specific column.  For example, an array with 3 rows and 3 columns and want to add more values to column 2.

 

The issue I'm having is that when I use the insert into array function, the information is only limited to the number of existing rows, therefore, LabView is not adding rows to accommodate the new values added to the column.  Here's an example:

 

C1, C2, C3             C1, C2, C3

01, 0A, 0B              01, 0A, 0B

02, 0C, 01              02, 0C, 01

05, 0C, 0T              05, 0C, 0T

                                     0B

                                     0C

 

Thanks!

                                     0M

0 Kudos
Message 1 of 10
(1,377 Views)

Use Build Array because Insert into Array will NOT add rows or columns.

 

array6.png

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 10
(1,373 Views)

Thanks for getting back to me.  I tried your method, however, the column ends up getting added to the bottom of the array as a row.  Is there a way to add it to the bottom of column 3?

 

floresma_0-1629313148961.png

 

Thanks,

0 Kudos
Message 3 of 10
(1,367 Views)

@RTSLVU wrote:

Insert into Array will NOT add rows or columns.


What do you mean by this? Build Array is 100% the better choice, but Insert into Array can definitely add a row to the end if you just don't wire the index inputs. I'm only asking for my own edification.

Spoiler
FireFistRedhawk_0-1629313340336.png

 

 

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

0 Kudos
Message 4 of 10
(1,366 Views)

I'm trying to add more elements to the bottom of a specific column of a 2D array, however, if I use the build array function and wire the 2D array to the first node and the 1D array of in formation to the second node, it adds the data as a row to the bottom of the 2D array table.  What I'm trying to do is add the information to the bottom of a column in vertical form.

 

For example, if I have a 2D array as the first set of data listed below.  And I want to add more data to the bottom of column 2.

 

floresma_0-1629313835300.png

 

0 Kudos
Message 5 of 10
(1,355 Views)

@floresma wrote:

Thanks for getting back to me.  I tried your method, however, the column ends up getting added to the bottom of the array as a row.  Is there a way to add it to the bottom of column 3?

 

 

 

Thanks,


NO,  you have to add an entire row or column. Because all rows and column of an array MUST be the same length.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 6 of 10
(1,354 Views)

@FireFist-Redhawk wrote:

@RTSLVU wrote:

Insert into Array will NOT add rows or columns.


What do you mean by this? Build Array is 100% the better choice, but Insert into Array can definitely add a row to the end if you just don't wire the index inputs. I'm only asking for my own edification.

Spoiler

 

 


Right... I was mistaken that it wont add a row.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 7 of 10
(1,349 Views)

I think you can transpose the array and add a row, then re-transpose it.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 10
(1,326 Views)

My take on your requirement, may not be the best but gets your job done and scalable.

 

santo_13_0-1629336756417.png

santo_13_1-1629336784595.png

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 9 of 10
(1,308 Views)

@floresma wrote:

For example, if I have a 2D array as the first set of data listed below.  And I want to add more data to the bottom of column 2.


Is this the entire task? What if you later want to add more data to one of the other columns, should the number of rows still grow by that amount or do you want to replace the existing zeroes?

 

For example

 

1 2 3
4 5 6

1 2 3
4 5 6
  7
  8

 

And you now want to add A B C to the first column, what should the result be?

 

1 2 3                 1 2 3
4 5 6 4 5 6
0 7 0 A 7 0
0 8 0 or B 8 0
A 0 0 C 0 0
B 0 0
C 0 0

 

Can you take a step back and explain the purpose of all this? Maybe you should implement it as a ragged array by having a 1D array of clusters, each containing a 1D array representing a column of arbitrary length.

 

Also, if you know the final 2D array size, maybe you should start with a 2D array of the final size, padded with zeroes..

 

 

 

0 Kudos
Message 10 of 10
(1,238 Views)