Dividing a vector into a matrix

1 view (last 30 days)
Colt Davis
Colt Davis on 19 Mar 2015
Edited: Andrei Bobrov on 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]

Accepted Answer

Star Strider
Star Strider on 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.)

More Answers (0)

Categories

Find more on Resizing and Reshaping Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!