LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

shift dimensions of n-D array

Solved!
Go to solution

I am trying to shift dimensions on a 3-D array, in order to go from dimension i,j,k to dimension j,k,i. With Matlab I would use shiftdim, with Python numpy.moveaxis, but I can't find a smart way to do this efficiently in LabVIEW.  I have found this old thread that is similar but not quite what I need. Is there a more general way to move around dimensions that efficiently deals with large arrays?

0 Kudos
Message 1 of 6
(2,146 Views)

AFAIK, there is no easy inbuilt way to swap dimensions.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 6
(2,105 Views)

Dunno any built-in method either.  I see basically 2 options, depending on your overall use case:

 

1. Manually copy all the elements into an array that indexes the way you prefer.  This would probably be the way to go if you need to do lots of subsequent processing involving auto-indexing based on the new layout.   Take the hit for copying 1 time, take advantage of the convenient layout many times.

 

2. Create your own wrapper function for indexing.  Leave the original array alone, but figure out how to use the indices from the desired layout to map to the correct indices in the actual layout.  This can be tricky to get right, and only lets you access one element at a time.  You won't be able to easily slice out a whole row, column, or page.

    My guess is that this method is unlikely to be preferable overall.

 

 

-Kevin P

 

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 3 of 6
(2,078 Views)

Try This

"If you weren't supposed to push it, it wouldn't be a button."
Message 4 of 6
(2,065 Views)
Solution
Accepted by blum22

Here's my quick attempt at a more general solution (Using Paul's input template. No guarantees 😄 )

 

altenbach_0-1667335388013.png

 

0 Kudos
Message 5 of 6
(2,027 Views)

Thank you all for your help. Unfortunately I got the flu right after posting this so I haven't been able to get back to it until yesterday. Altenbach's "general solution" seems to work well, however I had to flip the third and fourth arrangements in the subVI to get the right results.

I will update if I find any issues.

0 Kudos
Message 6 of 6
(1,966 Views)