How do you transpose a part of a column into more rows in Matlab?

조회 수: 2 (최근 30일)
Lisa Zarantonello
Lisa Zarantonello 2018년 11월 30일
댓글: the cyclist 2018년 12월 5일
Hi!
I imported an excel file in Matlab:
A1 A2 A3
B1 1 10 19
B2 2 11 20
B3 3 12 21
B4 4 13 22
B5 5 14 23
B6 6 15 24
B7 7 16 25
B8 8 17 26
B9 9 18 27
and I need to transpone the columns in rows as follow:
A1 A2 A3 A4 A5 A6 A7 A8 A9
B1 1 2 3 10 11 12 19 20 21
B2 4 5 6 13 14 15 22 23 24
B3 7 8 9 16 17 18 25 26 27
B4
B5
B6
B7
B8
B9
But note, the complete dataset I have is formed by 20 columns and 105 rows.
How can I do the transposition in the whole dataset?
Thank you!

채택된 답변

the cyclist
the cyclist 2018년 11월 30일
편집: the cyclist 2018년 11월 30일
If X is your original matrix ...
Y1 = reshape(X,3,3,[]);
Y2 = permute(Y1,[2,1,3]);
Y3 = reshape(Y2,3,9);
Y3 is the matrix you want as output.
You will probably need to use something other than 3 and 9 as the reshaping parameters, for your larger matrix.
  댓글 수: 2
the cyclist
the cyclist 2018년 12월 5일
No problem. The best form of thanks is to upvote and/or accept answers that were helpful. This rewards the person who helped you, and can guide future people looking for similar solutions.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by