05-13-2009 06:22 AM
Hi,
I have a problem with the "Insert into array" function. I'm trying to insert different size 2d arrays into a 3d array (see the attached vi). Works ok if the second array is smaller than the first one. But if I change the VI ("make this case 1") so that the smaller array is added first, all data from the bigger array is not inserted into the 3d array. Is there a workaround for this problem?
05-13-2009 06:30 AM
Yeah, basically arrays ll get truncated with the smallest date set size. What you can do is pad up your arrays with empty (if string) or 0 (if numeric) upto the size of the maxmimum subarray you would insert, and then insert these subarrays into the desired locations on the main array.
i think this should work. Post back here if you have problems still...
05-13-2009 06:33 AM
The problem is that you try to insert both arrays in the same dimension. Therefore, Insert Into Array checks for empty indices in the given dimension. If you have already elements present, Insert Into Array will not replace that element(s) but leave them out......
hope this helps,
Norbert
05-13-2009 06:37 AM
Norbert B wrote:
If you have already elements present, Insert Into Array will not replace that element(s) but leave them out......
Norbert,
I think "push them further" would be a more appropriate term here... right ?
05-13-2009 06:44 AM
Well, oddly not. The unmodified example postet here has only two elements (1xSize1, 1xSize2) in a 3D array after execution. If i change the case 1 to insert to another dimension, the array will include three elements (1x Size1, 2x Size2).
I think they key is:
The array you wire to n or n-1 dim array must be the same dimension or a dimension less than the one you wired to n-dim array. For example, you cannot insert a single element into a 2D array, and you cannot insert a single row (a 1D array) into a 3D array. You can, however, insert a 2D array that has a single row into a 3D array. LabVIEW pads the resulting array as necessary.
(Copy from the LV Help)
Because if i extend the first array to be 2D as well (currently it only contains a single element, so has "no dimension") by inserting another entry "Size 1", everything works as expected....
hope this helps,
Norbert
05-13-2009 06:45 AM
Sorry but I don't understand Norbert B's answer: "--The problem is that you try to insert both arrays in the same dimension. Therefore, Insert Into Array checks for empty indices in the given dimension. If you have already elements present, Insert Into Array will not replace that element(s) but leave them out......--"
I'm not inserting them into the same dimension, I'm inserting them into their own pages 0 and 1.
For parthabe: I guess I just have to find out what is the biggest array and pad the array according to it.
05-13-2009 06:57 AM
Ok, now it has data in all 2 dimensions (attached: arrays(modified))
But still it loses data (the Size 5)..
05-13-2009 06:58 AM
I dont have LV in my PC to cross-check you VI.
maybe once again you can verify whether you are inserting in the same dimension, like Norbert has mentioned or in different dimensions, like you have reiterated...
05-14-2009 12:23 AM
Hi,
Try this VI and check whether it satisfies your requirement.
05-14-2009 12:40 AM
I got what I wanted with the attached "Arrays(build array).vi".I used the "build array" instead of "insert into array".
Thanks for help!