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

3 ビュー (過去 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 件のコメント
Lisa Zarantonello
Lisa Zarantonello 2018 年 12 月 5 日
Thank you vey much!
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 Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by