10-31-2022 03:35 PM
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?
Solved! Go to Solution.
10-31-2022 06:32 PM
AFAIK, there is no easy inbuilt way to swap dimensions.
11-01-2022 06:31 AM
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
11-01-2022 07:33 AM
Try This
11-01-2022 03:43 PM - edited 11-01-2022 03:45 PM
Here's my quick attempt at a more general solution (Using Paul's input template. No guarantees 😄 )
11-08-2022 12:49 PM
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.