Dividing a vector into a matrix

2 visualizaciones (últimos 30 días)
Colt Davis
Colt Davis el 19 de Mzo. de 2015
Editada: Andrei Bobrov el 20 de Mzo. de 2015
I have a vector that has 40755 entries. I need to make this a multidimensional matrix where a new row is started every sixteenth entry. Any ideas? ex)
vector = [1,2,3,4,5,6,7,8,9,10,11,12]
split this up every third element
matrix [1,2,3
4,5,6
7,8,9,
10,11,12]

Respuesta aceptada

Star Strider
Star Strider el 20 de Mzo. de 2015
The reshape function is your friend!
I have no idea what shape you want your result matrix to be (it’s not clear from your question), so I can’t provide specific code. (The length of your vector is not evenly divisible by (12*16), so you have to be more specific with respect to what you want reshape to produce.)

Más respuestas (0)

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by