function v = expandVector(v, n)
%EXPANDVECTOR Replicate elements of a 1D vector.
%   V = EXPANDVECTOR(V, N) expands the vector V of size M, so that each of
%   its elements appears N consecutive times.
%
%   The result is a vector of size (length(V) * N) x 1.
%
%   See also: REPVEC

%   Author: Damien Teney

indices = zeros(1, length(v) * n);
indices(1 : n : length(v) * n) = 1;
indices = cumsum(indices);

v = v(indices);

v = v(:); % Ensure same behaviour when input V is a vector of a single element
