Mercurial > repos > public > sbplib
view vector2cell.m @ 207:d521e17f72b6 feature/grids
blockmatrix: Added function to create zero blockmatrices.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 15 Jun 2016 16:55:40 +0200 |
parents | a66aefd5e6ac |
children |
line wrap: on
line source
% Splits column vector v into segments of length n and returns the result as a column cell array. % v -- column vector to be split % n -- number of elements in each part % % cv -- cell array of vectors with lenght n(i) function cv = vector2cell(v,n) cv = cell(length(n),1); ind = [0; cumsum(n)]; for i = 1:length(n) ind_i = (ind(i)+1):ind(i+1); cv{i} = v(ind_i); end end