How do you transpose a part of a column into more rows in Matlab?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Lisa Zarantonello
le 30 Nov 2018
Commenté : the cyclist
le 5 Déc 2018
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!
0 commentaires
Réponse acceptée
the cyclist
le 30 Nov 2018
Modifié(e) : the cyclist
le 30 Nov 2018
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 commentaires
the cyclist
le 5 Déc 2018
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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!