LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I insert a number to a specific index (row and column) of an array

Solved!
Go to solution

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???

0 Kudos
Message 1 of 8
(5,421 Views)
Solution

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

Message 2 of 8
(5,414 Views)

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

 

 

 

 

Message Edited by DavidU on 11-04-2008 09:06 AM
Message 3 of 8
(5,411 Views)

 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.

 

 

 

 

 

 

 

 

Message 4 of 8
(5,398 Views)
I want to create something cool where whenever i click on the button i want it will automatically build an array list for me. but somehow im unable to make it work cause it cant build the array row by row automatically. please help advice. here is a diagram of my idea.
0 Kudos
Message 5 of 8
(5,245 Views)
You should start a new message thread as your question doesn't really seem to be related to this message thread.  Also, your front panel image really doesn't help in describing what you want to do.  Perhaps you can expand on the description of how you want these buttons to work when you start the new message thread.
0 Kudos
Message 6 of 8
(5,242 Views)

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.


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 7 of 8
(4,921 Views)

Sorry for the previous post!Just solved it using a shift register with for loop.

 

Regards.


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 8 of 8
(4,912 Views)