www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/RepeatVectorElementsExample.m

    %% Repeat Vector Elements
% Create a vector and repeat each of its elements three times into a new vector.

% Copyright 2015 The MathWorks, Inc.

v = [1 2 3 4];
u = repelem(v,3)

%%
% Repeat the first two elements of |v| twice and the last two elements
% three times.
u = repelem(v,[2 2 3 3])