LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Insert row to 2d Array

Solved!
Go to solution

Dear Friends,

I would like to add row to 2d array, I have developed below logic and unfortunately it gives me weird output and some how it changes the dimension of my array

it would be great if you can take a look to it and any help from your side is highly appreciated

Input array

3 6 6

9 8 5

5 6 7

row to insert zero: 2

Out put array

3 6 6

0 0 0

9 8 5

5 6 7

0 Kudos
Message 1 of 5
(5,093 Views)

Right-click the Insert into Array function, select Help, and read the Help.  It will explain that the second input (the black solid square) is "index 0, the point in the array at which you want to insert the row".  You don't put your array there, but you would put "1" if you want to insert at Array Position 1 (i.e. the second row).

 

It always helps to know how the function works, and reading the Help on the Function tells you.

 

Bob Schor

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

This looks exactly like what you are doing in your other thread, except Inserting rather than deleting.

 

Delete row (index is comming from an array) from source array

 

You should try to figure out the solutions given in that message thread before starting a new message thread asking about the exact same problems.

0 Kudos
Message 3 of 5
(5,080 Views)
Solution
Accepted by topic author arvin1947

Use a shift register for your source array instead of autoindexing.


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 4 of 5
(5,078 Views)

Also:

  • The array of rows should be integer (blue).
  • You typically should not autoindex on two arrays of different size (in the indexing dimension). The shorter one will determine the number of iterations and the size of the output.
  • You are not inserting a row, but extending an existing row or get nothing new (depending on the value of the insert point).
  • Unless you expect the "array" to change during the execution of the loop, the control belongs before the loop (if it is always three zeroes, use a diagram constant instead).
  • When attaching code, put typical values into your controls and make the value default so we don't need to guess.
  • From the number of (unique) rows, you can calculate the final size before the loop starts, so try to find an "in-place" solution that does not require incremental allocation of memory.

 

0 Kudos
Message 5 of 5
(5,075 Views)