LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

insert into array different sizes

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?  

 

0 Kudos
Message 1 of 18
(4,460 Views)

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

- Partha ( CLD until Oct 2024 🙂 )
0 Kudos
Message 2 of 18
(4,452 Views)

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 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 3 of 18
(4,446 Views)

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 ?

- Partha ( CLD until Oct 2024 🙂 )
0 Kudos
Message 4 of 18
(4,441 Views)

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 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 5 of 18
(4,434 Views)

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.

0 Kudos
Message 6 of 18
(4,433 Views)

Ok, now it has data in all 2 dimensions (attached: arrays(modified))

 

But still it loses data (the Size 5)..

0 Kudos
Message 7 of 18
(4,427 Views)

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

- Partha ( CLD until Oct 2024 🙂 )
0 Kudos
Message 8 of 18
(4,426 Views)

Hi,

 

Try this VI and check whether it satisfies your requirement.

Into the pursuit...
Maverick
0 Kudos
Message 9 of 18
(4,370 Views)

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!

0 Kudos
Message 10 of 18
(4,365 Views)