LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Odd behavior: Insert into Array (bug?)

So, I  ran across this today, and it totally befuddles me. Maybe someone can shed some light on it, or at least confirm the behavior. I am running this in 8.01 in WindowsXP within Parallels VM on a Macbook. I haven't had an opportunity to test this on a real PC, or in LV8.20.

It's a bit hard to explain, but the screenshot demonstrates the behavior. The subarray being inserted appears as zeros in the output array when it shouldn't. This doesn't occur if I don't use the Array Subset function, but the problem doesn't seem to manifest there (as you can see, the subarray has the correct value).

If you have any comment, I'd appreciate it. I'll post it as a bug if someone else can confirm.

Chris


Message Edited by C. Minnella on 11-30-2006 08:40 PM

Download All
0 Kudos
Message 1 of 9
(3,715 Views)
The VI you posted works properly in 8.2.
0 Kudos
Message 2 of 9
(3,708 Views)
Hi
 
I use LV8.0 on WinXP and just checked the behaviour of your vi. Basically I see the same as you do (0 in element 1). I also had a look at the vi's help where this is written:
 
If you do not wire any index inputs, the function appends the new element or subarray to the end of the n-dim array.
 
Unfortunately this does not really explain the behaviour.
 
In addition, I just wired a simple numeric (the random value out of the loop, indexing disabled) and it worked as one expects it. If I try to insert the arrays as in your example and wire an index, it works.
 
So I think this must be a bug, because it does not behave the same way in similar situations (simple numeric and no index / array and no index).
 
Thomas
 
p.s.: I always wire an index value - for me it makes the code more readable.
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 3 of 9
(3,700 Views)
Yes, seems buggy in 8.0, but works fine in 8.20. Time to upgrade. 😉
 
One thing that always puzzles me is the (ab)use of "insert into array" to append 1D arrays. To me it seems much more natural to use "built array" in concatenate mode to achieve the desired effect. (see image).
 

Message Edited by altenbach on 11-30-2006 11:34 PM

0 Kudos
Message 4 of 9
(3,698 Views)

Hi Christian - alive and kicking again?

I just can double the statement about the way of appending arrays of the same type to each other.

I'll wait until LV9.0 with the upgrade of my systems... 😉

Thomas

 

Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 5 of 9
(3,691 Views)
This is a peculiar bug indeed.  As this has been fixed for LabVIEW 8.2 I don't believe we need to take any further action on the R&D side. 

For people running into this bug I can suggest the following workaround: branch the wire (causing a copy of the data to be made in memory) and you see the behavior you would expect.

i.e.  this code works:



Regards,

Simon H
Applications Engineer
National Instruments

Message Edited by Simon H on 12-04-2006 12:26 PM

0 Kudos
Message 6 of 9
(3,651 Views)
This method may not be good for large arrays though wouldn't you agree. What would the solution be for large arrays?



Joe.
"NOTHING IS EVER EASY"
0 Kudos
Message 7 of 9
(3,644 Views)

Joe,

You seem to have two options.  You can either use the index on the insert into Array function (this clears up the problem).  If you simply want to append the array, you can find the size of the first array and use the size as the index.  You can also use the build array to concatenate.  Both of these methods will work around the problem.

I hope this helps.

Steven T.

0 Kudos
Message 8 of 9
(3,608 Views)
It seemed to work okay in my version of 8.0.1.
0 Kudos
Message 9 of 9
(3,573 Views)