Dividing a vector into a matrix

1 visualizzazione (ultimi 30 giorni)
Colt Davis
Colt Davis il 19 Mar 2015
Modificato: Andrei Bobrov il 20 Mar 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]

Risposta accettata

Star Strider
Star Strider il 20 Mar 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.)

Più risposte (0)

Categorie

Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by