10-22-2010 03:08 AM
I have a 2D array (nx1002) and a 1D array(1000).
It need to insert the 1D array into the 2D array at position of row X, colume 2.
This operation will keep running all the time, repeating with index X changing. Volume data may coming in.
Since 'insert into array' cost memory and not fit to use here, I tried to use 'replace array subset'.
But in 'replace array subset', cannot set one input as 2D array, another input as 1D array. Also I dont want to loop for 1000 time.
One way I think of is using the 'change dimension of the array' to change the 1D array into a 2D array, then can using the 'replace array subset'.
I am not sure if this is the correct way, or there are other nornal and good ways to do it. Thanks a lot.
Solved! Go to Solution.
10-22-2010 03:38 AM - edited 10-22-2010 03:39 AM
I have no issues overwriting part of a 2D array with a 1D array:

Ton
10-25-2010 07:55 AM
Thanks, got it.
That means it can only replace one entire row, cannot replace part of the row.
Not sure if I am right.
10-25-2010 09:08 AM
You can replace part of a row. You need to wire to both the row and column inputs to specify where the replacement will start. If the replacement is too large, the sub array is cropped to fit. See the detailed help file for Replace Array Subset for more details. Also it is often useful to wire a little test VI to try different things.
Lt=ynn
10-26-2010 01:23 AM
If I wire both row and column input, the input sub array must be 2D, cannot be 1D. If my data is 1D, it need to do a convert and take time cost.
10-26-2010 02:24 AM
10-26-2010 02:30 AM
The time cost to do a Reshape array to a 2D array is small, else you'll have to solve it slightly different.
- Extract row X through Index Array from 2D array
- Replace array subset in 1D extract (since you didn't want to change the full row)
- Replace row X in 2D array.
/Y
03-04-2019 12:27 AM
Hello,
following this topic, I propose to consider a 2D array and the replacement of a column by a new column.
The new column might have more or less elements that the old one. All unnecessary element will be filled by zeros.
For example, a 2D array of 3 columns has (let's say) 10 elements in column 0 (C0), 20 elements in C1, 5 elements in C2. So here, the size array will output 20. If I want to replace C2 by a new C2 of 3 elements, starting from row 0, then the other 16 elements from row 4 to 20 will be filled with zeros in the column C2. All other columns will not be modified.
So I build up a vi that intends to do it.
It seems to work, but there is a bug when the selected column is 0 or 1. I cannot understand why.
Can someone help me to understand ?
03-04-2019 01:20 AM - edited 03-04-2019 01:21 AM
Hi arienai,
It seems to work, but there is a bug when the selected column is 0 or 1. I cannot understand why. Can someone help me to understand ?
Why do you do all this so complicated?
Strip down to this:
(You still should check for valid column index and length of the replacement column!)
03-04-2019 03:18 AM
thank you very much GerdW,
yes you are right, your code is efficient.
My code was indeed more complex but it was for understanding my error. After looking to your code, I found that I used 2 times the insert to array, and the last one was creating unwanted output array.
Once again, I thank you very much for your valuable help,
Yours