From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

insert into array doesn't work

Please see attached screenshot & VI. I want to take a 1D array and break it into a 2-column array. The VI I have written works exactly right the FIRST time I run it. It puts the data in columns 0 and 1. The SECOND time I run it, it places the data into columns 2 and 3. Why does it do this? Since I hardwired the column index to 0, I expect it to OVERWRITE the first run of data and keep putting it into column 0 (and 1).
0 Kudos
Message 1 of 21
(5,108 Views)
Hi wb2nvy,
where is your attachment?
Mike
0 Kudos
Message 2 of 21
(5,104 Views)
Halarious.  -SS


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


0 Kudos
Message 3 of 21
(5,102 Views)
I thought I attached jpg and vi but I guess I didn't. Here they are... I hope.
0 Kudos
Message 4 of 21
(5,101 Views)
Only 1 attachment stuck. Here's the other one.
0 Kudos
Message 5 of 21
(5,098 Views)
Hi wb2nvy,
insert into, means that you insert new data into existing one, so you insert everytime your two arrays into your existing array with start at the first row.

Hope it helps.
Mike
0 Kudos
Message 6 of 21
(5,093 Views)
I half understand your answer Mike. I agree it should INSERT into the array the new data, BUT shouldn't it insert it where I TELL IT to insert it, which is starting at COLUMN 0, not ROW 0. I wired the COLUMN index to 0.
0 Kudos
Message 7 of 21
(5,084 Views)
The behavior you're seeing is due to the fact that you're using a local variable. The first time you run the VI the indicator is empty. The local variable returns an empty array. You run the VI, now the indicator has values. You run the VI again, now the local variable returns the values that are already there from the previous run.

If you're trying to convert a 1D array to a 2D array, why don't you just use the Reshape Array function?




Message Edited by smercurio_fc on 05-21-2008 03:53 PM
Message 8 of 21
(5,071 Views)
Yes I can use reshape array, but I still want to understand why Insert into array doesn't work. Even if I am using the local variable, I am TELLING the VI to put my data at column 0, regardless of what may already appear there by virtue of the local variable. Should the help file for Insert into array say something like "data will be inserted where you wire the index, UNLESS there's already data there, then all bets are off"?
0 Kudos
Message 9 of 21
(5,064 Views)
I don't understand what the confusion is about. Run the VI once, then change your array constant to something else. You will see those new values in columns 0 and 1.
0 Kudos
Message 10 of 21
(5,052 Views)