Effacer les filtres
Effacer les filtres

how to format vector as matrix?

1 vue (au cours des 30 derniers jours)
Berbia
Berbia le 1 Déc 2012
I have a long row vector say,v=[1 2 3 ... 100]. I'm in need to convert it into a matrix m=[1 2 3 4 5;6 7 8 9 10; ..... ;96 97 98 99 100] i.e),for each row 5 elements...Is it possible in matlab? if so how???

Réponse acceptée

Walter Roberson
Walter Roberson le 1 Déc 2012
m = reshape(v, 5, []) .' ;
Notice this first creates columns of 5 and then transposes so they become rows, rather than creating rows of 5 directly. This has to do with the order that reshape() takes elements to be reshaped.

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays 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!

Translated by