converting vector to matrix

Hello!
I want to convert vector:
V = [1 2 3 4 5 6 7 8 9]
To
V1 = [ 1 2 3; 4 5 6; 7 8 9 ]
Is there a Matlab command that will let me do this? or this needs to be coded? pleas help me Thanks in advence

Risposte (1)

Tom
Tom il 27 Giu 2012
doc reshape
in this case:
V1=reshape(V,3,3)

3 Commenti

Walter Roberson
Walter Roberson il 27 Giu 2012
Actually it would be
V1 = reshape(V,3,3) .'
reshape() goes down columns whereas zina wants to go across rows.
Tom
Tom il 27 Giu 2012
That's the last time I answer a question without having Matlab open.
Sean de Wolski
Sean de Wolski il 27 Giu 2012
@Tom, MATLAB Answers law 1:
-If you post something on MATLAB Answers without checking it, it will contain a typo!

Accedi per commentare.

Richiesto:

il 27 Giu 2012

Community Treasure Hunt

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

Start Hunting!

Translated by