Jump to content

Concatenate 2D array horizontally


Recommended Posts

I was working on something today and thought a "Concatenate Inputs Horizontally" would come in handy some times..

post-5791-125010968917_thumb.png

That way I could get rid of these 3 transpose array functions.

I'm usually not on the cutting edge of thought... something like this hasn't been discussed before, has it?

-James

  • Like 2
Link to comment

There's always many different ways to skin a cat. So here's one option I did which doesn't use any transpose array functions (since I was under the impression that it was bad on memory usage)

concathorizont.jpg

I just realized that this doesn't work in all use cases. If Array 2 has more rows than Array 1 then the output will not be exactly what you want, I guess the code could be modified to work properly. It's not often I need to concatenate horizontally but I wouldn't mind having it be a feature.

Link to comment

Yeah that works but it has the same flaw that mine had where things don't work right if the 2nd array has more rows than the 1st, but it is an improvement over my code.

Right, then we need to check for this and concenate the missing lines to the first array. Or use the initial solution using transpose arrays which is applicable to 2D-arrays only

Edited by unicorn
Link to comment

There's always many different ways to skin a cat. So here's one option I did which doesn't use any transpose array functions (since I was under the impression that it was bad on memory usage)

Transpose Array is under such circumstances usually almost a NOP. Thanks to LabVIEW having something like sub-arrays.

Rolf Kalbermatter

  • Like 1
Link to comment
  • 4 years later...

Revive a 5 year old thread?  Why not.  Turns out there is a easier way to concatenate a 2D array of numerics horizontally using the matrix math build matrix function. There is a right click option for append columns, or append rows.

 

http://forums.ni.com/t5/LabVIEW/Concatenate-2d-arrays/m-p/2959175#M853118

Believe it only works for numerics though.

Edited by GregFreeman
Link to comment
  • 4 years later...

But surely all of these are slower and more memory wasteful than transposing which simply twiddles the order and offsets of the pointers that are used to index the block of memory in which the array resides? 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.