view vector2cell.m @ 404:d6d27fdc342a

Merged in feature/SBPinTimeClarity (pull request #5) Feature/sbpintimeclarity Approved-by: Martin Almquist
author Martin Almquist <martin.almquist@it.uu.se>
date Thu, 02 Feb 2017 14:46:36 +0000
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