LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

insert into array doesn't work

What makes you think the Insert Into Array is not working properly and that data is being put into columns 2 and 3 on the second run? If you run the VI a second time with different values for the input array you will see that the Insert Into Array is operating properly. The attached modication is in essence doing this:



Insert into array is insert, not overwrite. If you want it to overwrite, use Replace Array Subset.


Message Edited by smercurio_fc on 05-21-2008 04:11 PM
0 Kudos
Message 11 of 21
(2,580 Views)

Dennis,

I can understand wb2nvy's confusion.  When I originally ran the vi it looked like the index was moving the data higher and higher into the array.  When in fact the new data is being pushed to index 0 of the existing array, but since the data looks the same, it gives the illusion as it is being indexed incorrectly.  Your suggestion of changing the value removes this illusionJ

On a side note I thought maybe he was looking to split the array at an odd point.  This would leave the array in two pieces that are different sizes.  Then I started thinking how do you make this re-shape properly?  And I came up with the attached solution.

*How do you get the png to appear;)

Regards,

-SS



Message Edited by ShotSimon on 05-21-2008 04:34 PM

Message Edited by ShotSimon on 05-21-2008 04:35 PM


0 Kudos
Message 12 of 21
(2,571 Views)

ShotSimon wrote:

*How do you get the png to appear;)


1) attach the .png file as usual.
2) open the attachment. copy the url.
3) Edit the original post and click "Insert an image" (shown in the attachement)
 
and paste the url.
4) post it again. achieved ur wish.
 
Thanks,
Mathan


Message Edited by mathan on 05-21-2008 11:54 PM
Message 13 of 21
(2,549 Views)
Yes Dennis, your suggestion works. NOW explain to me WHY it should work. If I tell the Insert into array to put my data at column ZERO, why doesn't it PUT IT THERE EVERY TIME and overwrite if necessary? And if after filling columns 0 and 1 I then tell it to put data at column 5, WHY DOES IT PUT MY DATA AT COLUMN 0????  It doesn't make sense.
0 Kudos
Message 14 of 21
(2,529 Views)
If you want to overwrite data, you need to use Replace Array Subset.  If you use Insert Into Array, it will always insert new data and increase the size of your array.
0 Kudos
Message 15 of 21
(2,522 Views)
Oh and also, you can only insert into an existing array index.  So when you try to insert into column 5, nothing is happening.  If you right click on your indicator and select data operations->reinitialize value to default and try to insert at column 5, you'll still have an empty indicator.  Basically, insert has to have existing data to put your new data in front of.
0 Kudos
Message 16 of 21
(2,518 Views)
ShotSimon- you hit the proverbial nail on the head. You understand my confusion, and you cleared it for me. I now understand my data IS going where I tell it to, and the OLD data is being pushed aside. And I also now know that I can't put data into column 5, for example, without first initializing the array with something. Thank you all very much for your help.   I JUST WISH THE N.I. DOCUMENTATION WOULD HAVE SAID THAT & SAVED US ALL SOME TIME AND FORUM SPACE.
0 Kudos
Message 17 of 21
(2,510 Views)
So the example that I provided which clearly showed what was going on wasn't obvious enough? Also, the Help for Insert Into Array says:

    Inserts an element or subarray into n-dim array at the point you specify in index.

For the "index" input it says
index 0..n-1 specifies the point in the array at which you want to insert the element, row, column, page, and so on. You can wire only one index input. For example, to insert a 1D array as the fourth row of a 2D array, wire 3 to the first index input, and the second index input becomes disabled. To insert the array as the fourth column of the 2D array, wire 3 to the second index input, and the first index input becomes disabled.
How much more clear than that can you be? It also would be redundant to say that you can't insert into a column that doesn't exist, because ... it doesn't exist! That action is undefined.
0 Kudos
Message 18 of 21
(2,483 Views)
smercurio, I'm sorry if I hurt your feelings by not understanding your response. Fact is, you clearly didn't understand what I was trying to accomplish. Your example of using Reshape Array didn't result in what I was trying to do. In fact it CAN'T be done with Reshape Array. If you look at the example I posted, it does not resemble your proposed solution. I attached what I finally found worked, using 2 Array Subsets and a Transpose.
0 Kudos
Message 19 of 21
(2,471 Views)
I wasn't referring to the Reshape Array example. I was referring to the example in post #11 (at the top of this page with a great big figure).

My feelings weren't hurt. I just found it curious that the example clearly showed what you said with "I now understand my data IS going where I tell it to, and the OLD data is being pushed aside."

Whatever. As long as you understand now that Insert Into Array is not broken and that it operates exactly as designed and described.

Also, just to prove to you that Reshape Array does work:




Message Edited by smercurio_fc on 05-22-2008 09:41 AM
0 Kudos
Message 20 of 21
(2,461 Views)