LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I insert a 1D array into 2D array without shifting the data down?

I am using the insert into array vi at the second to insert a row into a 2D array, however when I do this is it shifts the orginal data down by 1 row.

 

Build array isn't sufficient because I need control over which row I put the data in.

 

For example if I have the 2D array;

 

1 1 1 1

2 2 2 2

3 3 3 3 

4 4 4 4

 

And I use the insert into array to insert 8 8 8 8 into row 2 it does this;

 

1 1 1 1

2 2 2 2

8 8 8 8 

3 3 3 3

4 4 4 4

 

Rather than 

 

1 1 1 1 

2 2 2 2

8 8 8 8

4 4 4 4

 

Is there anyway to easily achieve this?

 

 Let me know if you need any more info.

 

Thanks,

 

Jack

0 Kudos
Message 1 of 5
(2,894 Views)

All programming indexes start from 0, not 1!

 

So if you want 8888 to be in the 2nd row, you would insert it into row index 1.

 

In other words, the rows in an array are indexed:

0

1

2

3

4

....

 

 

not:

1

2

3

4

....

Message Edited by Cory K on 04-23-2009 11:35 AM
Cory K
0 Kudos
Message 2 of 5
(2,892 Views)
And the functionality that you are describing sounds like you want to replace array subset. But that sounds too easy.
PaulG.
Retired
0 Kudos
Message 3 of 5
(2,887 Views)

I read the op as "replace array subset" is the exact solution he is looking for. I don't think it was a problem with the index value, but seemed to be a problem of "making space for" the new array instead of "overwriting" the previous one.

 

Let us know is this VI is what you are looking for.

Chris Van Horn
Applications Engineer
0 Kudos
Message 4 of 5
(2,869 Views)

Ok,

Replace array subset is what I was looking for I think. I'll try it out.

 

What I meant earlier is; if you have the array (with row indexing on the left)

 

0: 1 1 1 1

1: 2 2 2 2

2: 3 3 3 3 

3: 4 4 4 4

 

And you want to put 8888 into array with the insert into array vi, at row 2, it becomes 

 

0: 1 1 1 1

1: 2 2 2 2

2: 8 8 8 8

3: 3 3 3 3

4: 4 4 4 4

 

 

But I want it to look like 

 

0: 1 1 1 1

1: 2 2 2 2

2: 8 8 8 8

3: 4 4 4 4 

 

So I have overwritten row 2, taking into account array indexing starts at 0 🙂

 

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