LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

transpose 3d array

I've just got a question.. to transpose a 3d array, can I just convert to matrix, transpose matrix, convert to array?? Anyone tried it? My equipment  is getting repaired, so I can't compare the code yet. Thanks
0 Kudos
Message 1 of 6
(3,613 Views)
First you need to better define your transpose operation.  In 3D it is not well-defined (as far as I know).   Second, only 2D arrays can be converted to matrices.  Finally, do you need to "transpose" your array and pass it to another VI or are you doing the manipulation yourself.  I ask this because in C I would simply change the pointer math and leave the array alone.  In LV this would mean leaving the array alone but changing how you index it depending on whether you were dealing with the matrix or its transpose.
Message 2 of 6
(3,600 Views)

You would first need to define what you mean by transposing a 3D array, as it depends on what you're swapping. Also, there's no need to use the matrix datatype - stick with arrays. Have you tried a search? This has come up before:

 

http://forums.ni.com/ni/board/message?board.id=170&message.id=218890

http://forums.ni.com/ni/board/message?board.id=170&message.id=63107

Message 3 of 6
(3,597 Views)

Darin.K wrote:
First you need to better define your transpose operation.  In 3D it is not well-defined (as far as I know).   Second, only 2D arrays can be converted to matrices.  Finally, do you need to "transpose" your array and pass it to another VI or are you doing the manipulation yourself.  I ask this because in C I would simply change the pointer math and leave the array alone.  In LV this would mean leaving the array alone but changing how you index it depending on whether you were dealing with the matrix or its transpose.

Yeah, question marks were going through my head about 3D transposing because I can think of two different ways it can be "flipped on its side."  Convertible matressess sounds like a futon.  LOL glad to see someone uses the "proper" plural of "matrix."  Now let's see you use "indices" somewhere in your next post!  Kudos.  🙂

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 4 of 6
(3,595 Views)
Thanks for suggesting the other threads. I think they address my issue very well. I appreciate the tip. 🙂
0 Kudos
Message 5 of 6
(3,587 Views)

if you transpose in 2D you swap rows for columns.

 

Basically you change the order in which the arrays are indexed if you would use stacked FOR loops.

 

If we retain the analogy for 3D arrays, there are several swaps possible.  

Starting with x,y,z, we get several possibilities:

 

x,z,y 

y,x,z

y,z,x

z,y,x

z,x,y

 

Any of the five can be done very efficiently. Are all dimensions the same?

0 Kudos
Message 6 of 6
(3,566 Views)