From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

How to add 2D array at the end of another 2D array

Hello,

how can i a add two 2D arrays together so that array two is not after it but at the end as marked in screenshot?

Thx for help

 

best regards

TM

Download All
0 Kudos
Message 1 of 14
(1,933 Views)

Like this:

ca.png

That extra function I added is: Functions -> Programming -> Array -> Matrix -> Matrix Size

"If you weren't supposed to push it, it wouldn't be a button."
Message 2 of 14
(1,928 Views)

Don't over-complicate things! The correct function is "built array". Make sure to set it to "concatenate" mode by right-clicking. No need to get dimensions, etc.

 

altenbach_0-1595949731281.png

 

("Insert into array" is a much more complicated function, requires more inputs, and is most useful if you want to insert somewhere in the middle. It is not needed here!)

 

0 Kudos
Message 3 of 14
(1,903 Views)

Actually, the OP wanted the 2nd array to the right of the first array and not below.

 

I, myself, would have used Build Array, but with Transpose Array a few times to locate the 2nd array.

 

 

One thing Altenbach does basically say is that Build Array is usually the right answer over Insert Into Array.  I'd say 90% of the time where someone has been using Insert Into Array, they probably only needed Build Array.  I think I can count on one hand the number of times in my LabVIEW programming I've needed "Insert Into Array".

0 Kudos
Message 4 of 14
(1,895 Views)

@RavensFan wrote:

Actually, the OP wanted the 2nd array to the right of the first array and not below.

 


Sorry, for misreading. Sometimes it is difficult to know what the OP wants vs what he gets. 😉

 

(The title was somewhat misleading, stating "...at the end of another 2D array". The way 2D arrays are arranged in memory, my solution was closer to the description. To append rows, the data needs to be interlaced in memory, which is more effort!)

 

 

Assuming that the array have the same number of rows, there is no need to transpose. Just add a FOR loop.

 

altenbach_0-1595950522075.png

 

 

 

0 Kudos
Message 5 of 14
(1,886 Views)

Thx for all help. meanwhile i solved it too

0 Kudos
Message 6 of 14
(1,872 Views)

@altenbach wrote:

@RavensFan wrote:

Actually, the OP wanted the 2nd array to the right of the first array and not below.

 


Sorry, for misreading. Sometimes it is difficult to know what the OP wants vs what he gets. 😉

 

(The title was somewhat misleading, stating "...at the end of another 2D array". The way 2D arrays are arranged in memory, my solution was closer to the description. To append rows, the data needs to be interlaced in memory, which is more effort!)

 

 

Assuming that the array have the same number of rows, there is no need to transpose. Just add a FOR loop.

 

altenbach_0-1595950522075.png

 

 

 


Technically, transpose is probably quicker.  It's probably a no-op, I would think.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 14
(1,858 Views)

@OnlyOne wrote:

Thx for all help. meanwhile i solved it too


Of course the general case would need better specifications. Do the array sizes match in some ways (Do the number of rows match? Columns? Both? etc. How should they be aligned/padded if the sizes don't match? etc.)

 

If this is just a one-shot deal, you are probably fine, but if you for example want to keep appending new arrays over and over, you should probably re-think your data structures and make sure that the new data is kept mostly consecutive in memory by keeping it transposed. Just think about it! 😉

0 Kudos
Message 8 of 14
(1,854 Views)

@billko wrote:
Technically, transpose is probably quicker.  It's probably a no-op, I would think.

Probably not, because the two arrays need to be interlaced in memory, requiring a new allocation.

(Technically, the compiler might actually create the exact same binary code for both versions. ;))

0 Kudos
Message 9 of 14
(1,850 Views)

@altenbach wrote:

@billko wrote:
Technically, transpose is probably quicker.  It's probably a no-op, I would think.

Probably not, because the two arrays need to be interlaced in memory, requiring a new allocation.

(Technically, the compiler might actually create the exact same binary code for both versions. ;))


I was thinking that the memory would just be "reconsidered" as is the case with a reversed string, but you're saying that manipulating a multi-dimensional array would be more complicated?  In other words, LV would actually have to re-create the data, not "reconsider" it?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 10 of 14
(1,847 Views)