LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

split 2D array to 1D arrays by row

Solved!
Go to solution

Hi

 

I am trying to do 2 things with arrays and their dimensions. They both seem quite basic, but I can't figure out how to do them...

 

1. Split a 2D array of size 2 x N into two 1D arrays of length N.

 

2. Reshape a 2D array of size m x n into a 1D array of length mn, then do the inverse procedure and get it back to a 2D m x n array. (After doing some manipulation, interpolation, etc.)

 

Thanks!

0 Kudos
Message 1 of 9
(38,558 Views)
Solution
Accepted by MOI_maker

1.  Index Array.

2.  Reshape array.  Though you will probably need to look at the array size and do some math to feed the values into the Reshape array function.

Message 2 of 9
(38,554 Views)

Man, I knew it would be simple...

 

 

I had to muck around a bit with array size and array index for part 2, to get the modified array back to it's original dimensions, but it wasn't too difficult.

 

Thanks.

0 Kudos
Message 3 of 9
(38,547 Views)

I spent 10 minutes mulling over this same problem today. It turns out this is so simple in LabVIEW it's embarassing, here's MxN to M N's.

 

bd.png

 

fp.png

justinmreina@gmail.com
Message 4 of 9
(27,868 Views)

@Justin_Reina wrote:

I spent 10 minutes mulling over this same problem today. It turns out this is so simple in LabVIEW it's embarassing, here's MxN to M N's.


From what I can tell, you are "solving" a problem that has nothing to do with the original discussion of this five year old thread. (That has already been marked as solved!)

 

Can you explain the point of your post and what you are trying to solve.

 

(Typically, 1D arrays of clusters of 1D arrays  are useful to represent "ragged 2D arrays", which is not the case in your example. Please clarify.)

0 Kudos
Message 5 of 9
(27,820 Views)

Back to the original question -

 

1. Split a 2D array of 2xN into (2) 1D arrays of len N

 

     This code achieves this. It uses the cluster datatype to conceptually & visually segment

      the problem-statement's solution - try to make a cleaner visual solution

 

To your question -

 

Typically, 1D arrays of clusters of 1D arrays  are useful to represent "ragged 2D arrays",

which is not the case in your example. Please clarify

 

    I don't care about ragged 2D arrays, AKA 'sloppy programming' ... See the answer above

    for my clarifications. I used an array of clusters here for conceptual visualization. I use this

    sometimes(rarely!) in practice at work when I need visual clarity momentarily. Sometimes...

 

So ummm, thanks for your direct & public sarcasm but I would suggest that occur on the side in email in the future...

 

-Justin 😉

 

 

justinmreina@gmail.com
Message 6 of 9
(27,758 Views)

@Justin_Reina wrote:

Back to the original question -

 

1. Split a 2D array of 2xN into (2) 1D arrays of len N

 

     This code achieves this. It uses the cluster datatype to conceptually & visually segment

      the problem-statement's solution - try to make a cleaner visual solution


A cleaner visual solution would be to just leave it as a 2D array! The existing display of rows and columns is very clear and easy to view and understand! Why all that song and dance of using complicated hierachical structures? Since when did the word "split" mean "wrap it into a complicated structure for easier viewing"?


@Justin_Reina wrote:

 I don't care about ragged 2D arrays, AKA 'sloppy programming' ... See the answer above

    for my clarifications.


Ragged arrays have nothing to do with sloppy programming. They are a valid data structure useful for certain scenarios.


@Justin_Reina wrote:

So ummm, thanks for your direct & public sarcasm but I would suggest that occur on the side in email in the future...


Well, a public post deserves a public answer. I am probably not the only one confused by your post dangling from the end of an ancient solved thread so a public clarification is beneficial to all. Besides, your e-mail address is probably not public and even if I had it, e-mailing somebody out of the blue would need a very, very good reason. I rarely do that.

 

I just asked for clarification and pointed out what parts of your posts confused me in the context of the original thread. No sarcasm anywhere.

Message 7 of 9
(27,731 Views)
Leave it 2D, good point indeed!! 🙂
justinmreina@gmail.com
0 Kudos
Message 8 of 9
(27,723 Views)

I would strongly recommend NOT to put e-mail addresses in public posts or even signatures. They WILL get harvested by spammers.

Message 9 of 9
(27,712 Views)