Jump to content
James N

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

..

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

-James

James! Drink less beer.biggrin.gif

What's about the attached VI (LV 8.6)? I tested it for two dimensions and one case only.

horizontal concenate.vi

Share this post


Link to post
Share on other sites

James! Drink less beer.biggrin.gif

What's about the attached VI (LV 8.6)? I tested it for two dimensions and one case only.

horizontal concenate.vi

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

  • Like 1

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Believe it only works for numerics though.

Yup that's what I said.

Share this post


Link to post
Share on other sites

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? 

Share this post


Link to post
Share on other sites

Join the conversation

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

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