I have a 4 Dimensional Matrix and i want to get its transpose

조회 수: 21 (최근 30일)
Nir Vaishnav
Nir Vaishnav 2022년 7월 20일
편집: James Tursa 2022년 7월 20일
val(:,:,1,1) =
-0.0011 + 0.0005i -0.0001 - 0.0006i 0.0005 - 0.0004i 0.0004 - 0.0005i
0.0001 - 0.0002i 0.0005 - 0.0006i -0.0001 - 0.0003i 0.0001 - 0.0005i
val(:,:,2,1) =
1.0e-03 *
0.0853 + 0.0961i -0.0836 + 0.5605i -0.2264 - 0.2537i -0.4819 + 0.4021i
0.2431 - 0.0009i 0.0080 - 0.1446i 0.0173 - 0.3306i 0.3036 + 0.0662i
val(:,:,3,1) =
1.0e-03 *
0.4071 + 0.1592i 0.0390 + 0.0368i 0.1849 + 0.1427i 0.1037 - 0.0101i
-0.3148 + 0.4124i 0.1739 - 0.8511i 0.4364 + 0.2318i -0.4959 - 0.0581i
val(:,:,4,1) =
1.0e-03 *
-0.3427 - 0.2354i -0.0962 + 0.2063i 0.0545 - 0.5590i 0.4838 - 0.4740i
-0.1377 + 0.3177i 0.4218 - 0.1650i 0.5585 - 0.0281i 0.8008 + 0.3560i
val(:,:,1,2) =
0.0000 + 0.0005i -0.0005 - 0.0001i 0.0009 + 0.0005i -0.0003 - 0.0004i
-0.0003 - 0.0001i -0.0001 - 0.0003i 0.0001 - 0.0007i 0.0010 - 0.0008i
val(:,:,2,2) =
1.0e-03 *
0.0735 - 0.0389i 0.2078 + 0.6834i -0.4282 + 0.1815i 0.0376 + 0.1491i
0.5771 + 0.3827i 0.2349 - 0.0414i 0.3709 + 0.4640i -0.1642 + 0.0532i
val(:,:,3,2) =
1.0e-03 *
-0.2583 + 0.1898i -0.6208 - 0.1740i -0.6824 + 0.6126i 0.7040 + 0.1055i
-0.5507 - 0.5081i 0.2960 + 0.1625i -0.3143 + 0.2994i -0.2992 + 0.1128i
val(:,:,4,2) =
1.0e-03 *
0.3043 + 0.5059i -0.1311 + 0.4960i 0.1339 - 0.1343i -0.3379 - 0.1514i
0.6952 + 0.5950i 0.1602 + 0.3575i 0.6829 + 0.7096i 0.4307 - 0.7628i
So this is my 4 dimensional matrix and i want to find its transpose using a for loop.
  댓글 수: 5
James Tursa
James Tursa 2022년 7월 20일
편집: James Tursa 2022년 7월 20일
@Torsten "A requirement for a (2d)-matrix to have a transpose is that it is square."
Huh? Of course one can transpose any size 2D matrix. E.g.,
A = [1 2 3 4; 5 6 7 8]
A = 2×4
1 2 3 4 5 6 7 8
A.'
ans = 4×2
1 5 2 6 3 7 4 8
Torsten
Torsten 2022년 7월 20일
A requirement for a (2d)-matrix to have a transpose is that it is square.
Ok, it's nonsense.

댓글을 달려면 로그인하십시오.

답변 (2개)

Jon
Jon 2022년 7월 20일
편집: Jon 2022년 7월 20일
You can use the MATLAB permute function for this and not use any loops
  댓글 수: 2
Nir Vaishnav
Nir Vaishnav 2022년 7월 20일
how do i use it in code?......i am still unclear after seeing the help file.
Jon
Jon 2022년 7월 20일
Let me first ask, what is it that you actually want to do. What exactly do you mean by the "transpose" of a 4 dimensional array. Ideally please provide a simple example, of your desired input array and output array.

댓글을 달려면 로그인하십시오.


James Tursa
James Tursa 2022년 7월 20일
편집: James Tursa 2022년 7월 20일
Maybe this does what you want, which is transpose the first two dimensions:
permute(val,[2 1 3 4])
Or you could use this function to get the same result:
pagetranspose(val)

카테고리

Help CenterFile Exchange에서 Elementary Math에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by