No BSD License  

Highlights from
Multi Dimension Transpose

1.0

1.0 | 1 rating Rate this file 2 Downloads (last 30 days) File Size: 497 Bytes File ID: #7419

Multi Dimension Transpose

by Aman Siddiqi

 

11 Apr 2005 (Updated 02 May 2005)

Transposes each plane of an N dimension matrix.

| Watch this File

File Information
Description

multi_dimension_transpose works for N dimensions transposing each plane individualy. It maintains the existing dimension structure above the first two without any squeeze.

MATLAB release MATLAB 6.5 (R13)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
15 Apr 2005 Jos x

Nice try but your code equals
permute(A,[2 1 3:ndims(A)])
in which A is an N-dimensional matrix (N >= 2).

Moreover, it's _much_ slower!
>> A = rand(2,3,4,5,6,7,8,9) ;
>> tic ; B = multi_dimension_transpose(A) ; toc ;
elapsed_time = 42.2970
>> tic ; C = permute(A,[2 1 3:ndims(A)]) ; toc ;
elapsed_time = 0
>> all(C(:)==B(:))
ans = 1

05 May 2005 Aman Siddiqi

I implemented the permute code suggested by Jos x. It now runs much faster.
Its still nice to have in one script so the matrix isn't referenced twice and for those who don't know the permute code.

15 Oct 2009 Jan Simon

All it does is Jos x's suggested line:
  A = permute(A, [2, 1, 3:ndims(A)]);
after a not documented test "if isfinite(matrix);", which might be rarely useful: The function does not define the output, if all matric elements are INFs.
Although it works at least, the single call to PERMUTE is still faster and more reliable => 1 star.

Please login to add a comment or rating.
Updates
02 May 2005

Increased speed

Tag Activity for this File
Tag Applied By Date/Time
matrices Aman Siddiqi 22 Oct 2008 07:45:39
three Aman Siddiqi 22 Oct 2008 07:45:39
ndimension Aman Siddiqi 22 Oct 2008 07:45:39
matrix manipulation Aman Siddiqi 22 Oct 2008 07:45:39
multi dimension transpose Aman Siddiqi 22 Oct 2008 07:45:39
affine transformation fourier ZHAO QIUJI 11 Jun 2010 02:27:49

Contact us at files@mathworks.com