11-04-2008 02:47 AM
I've been having the most trouble with "insert into array" function because of it's counter-intuitiveness. I want to insert a number that I've obtained inside a FOR-loop into an array. The ROW and COLUMN of that array that I want to enter the number is specified by the loop count of two FOR-loops. It didn't work.
So, I isolated and tested this function further. I plainly initialized a 2-D array with all ZEROS and plugged it into the "insert into array" function (the top input). I then put the number "1" for the index (row) and the number "2" for the index (column) and then put the number "6" for the "new element/subarray" input. Then, I hooked up a 2-D output (indicator) array to the output of the "insert into array" function. When I did all this it means that I just want to put the number "6" into row "1" and column "2".....it's not letting me do that.
How can I perform this SIMPLE operation???
Solved! Go to Solution.
11-04-2008 02:57 AM
Hi Darrell h...,
it sounds like you can use the function "autoindexing". Take your value and connect it to your loop, it will be autoindexing as default. right click on the last output tunnel and select create indicator, the result is your array.
Hope it helps.
Mike
11-04-2008 03:05 AM - edited 11-04-2008 03:06 AM
I think what you are after is the 'replace array subset', rather than the 'insert into array'. Replace array subset will let you put a value into an already existing array, and will overwrite whatever is already there. Insert into array actually adds a new element at the point you specify and increases the size of the array.
Also note that the array is zero indexed, ie the first row is row 0 and the first column is column 0. So to change the value in first row and second column of the array as it appears on screen you have to wire the indices as 0 and 1.
See the attached vi.
Hope this helps, if not post your code so we can have a look.
Dave
11-04-2008 03:18 AM
I think you'd rather use the function "replace subset" if you want to "put" a "6" at index {1,2}. "Insert" function will modify the size of your array.
12-18-2008 08:33 PM
12-18-2008 08:57 PM
12-01-2009 04:27 AM
Hello!
I have an array of numbers, which I want to insert into a pre-initialized empty array. The indexes (both row and column) are specified (for column indexes I also have an array of numbers, for rows I will use a for loop from 0 to n-1 rows). This is a simple task in a program like matlab, but it seems I'am not thinking in the right direction in labview...
So I would like to insert an array of numbers into an empty array at specific indexes. I used replace array subset, but I can't manage to solve the problem. How is this possible (not regarding my ability to solve the problem, but the problem itself :))?
Thank you very much.
Regards,
Klemen P.
12-01-2009 04:50 AM
Sorry for the previous post!Just solved it using a shift register with for loop.
Regards.