LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

inserting 1D array into another one

Solved!
Go to solution

hello everyone:
I have complex 1D array of length(3000) and I want to insert another 1D array of length (1200) into the first one starting at index (500) of the first array the output array should with a length (3000) , the problem is that the resulting array with length(4200) not (3000) ?!

0 Kudos
Message 1 of 6
(2,298 Views)

Hi ashly,

 


@ASHLY19 wrote:

I have complex 1D array of length(3000) and I want to insert another 1D array of length (1200) into the first one starting at index (500) of the first array the output array should with a length (3000) , the problem is that the resulting array with length(4200) not (3000) ?!


Why is it a problem when the resulting array contains 4200 elements - after you inserted 1200 elements into your 3000 elements array?

Do you want to insert new elements or do you want to replace elements?

 

Two options to get a resulting array of 3000 elements:

  1. use ArraySubset to get a subset of 3000 elements from your 4200 elements array
  2. use ReplaceArraySubset instead of InsertIntoArray…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(2,286 Views)

You're doing it wrong.

 

Show us the code...

0 Kudos
Message 3 of 6
(2,286 Views)

I want the two arrays overlapped not concatenated as shown the following figures ni1.png

 

ni2.png

 

0 Kudos
Message 4 of 6
(2,267 Views)

As GerdW mentioned, it sounds like what you want to do is replace array elements, not insert into array. Replace array elements will write the elements from the smaller array over the elements of the larger array.

0 Kudos
Message 5 of 6
(2,260 Views)
Solution
Accepted by topic author ASHLY19

The Add simply creates an output of the smallest input size.

 

The "Insert Into Array" inserts into an array (yes, really 😉).

 

It's not clear how exactly you want this 'overlap' to happen? Is the Add an attempt, just a test or the requirement?

 

If you want to add the two arrays, first make sure they are the same size. If addition is the goal, grow the smallest array to the size of the larger one (either calculate the sizes and concatenate the missing data, or use Resize Array), then use Add.

0 Kudos
Message 6 of 6
(2,255 Views)