04-23-2009 11:29 AM
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
04-23-2009 11:34 AM - edited 04-23-2009 11:35 AM
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
....
04-23-2009 11:39 AM
04-23-2009 12:44 PM
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.
04-24-2009 03:11 AM
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 🙂