Main Content Show
repelemRepeat copies of array elements SyntaxDescriptionexample
This syntax is not supported for example
Examplescollapse all Repeat Vector ElementsCreate a vector and repeat each of its elements three times into a new vector. v = [1 2 3 4]; u = repelem(v,3) u = 1×12
1 1 1 2 2 2 3 3 3 4 4 4
Repeat the first two elements of u = 1×10
1 1 2 2 3 3 3 4 4 4
Repeat Matrix ElementsCreate a matrix and repeat each element into a 3-by-2 block of a new matrix. B = 6×4
1 1 2 2
1 1 2 2
1 1 2 2
3 3 4 4
3 3 4 4
3 3 4 4
Repeat Matrix ColumnsCreate a matrix and copy its columns into a new array, repeating the first column twice and second column three times. B = 2×5
1 1 2 2 2
3 3 4 4 4
Input Argumentscollapse all v — Input element scalar | vectorInput element, specified as a scalar or a vector. Data Types: n — Number of times to repeat each element scalar | vectorNumber of times to repeat each element, specified as a scalar or a vector. If Data Types: A — Input array matrix | multidimensional arrayInput array, specified as a matrix or multidimensional array. Data Types: r1,...,rN — Repetition factors for each dimension (as separate arguments) scalars | vectorsRepetition factors for each dimension, specified as separate arguments of integer-valued scalars or vectors. If Data Types: Output Argumentscollapse all u — Output vector vectorOutput vector. If Data Types: B — Output array matrix | multidimensional arrayOutput array, returned as a matrix or multidimensional array. Data Types:
Extended CapabilitiesTall Arrays Calculate with arrays that have more rows than fit in memory.This function supports tall arrays with the limitations:
For more information, see Tall Arrays. C/C++ Code Generation Generate C and C++ code using MATLAB® Coder™.Usage notes and limitations:
GPU Code Generation Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.Usage notes and limitations:
Thread-Based Environment Run code in the background using MATLAB® backgroundPool or accelerate code with Parallel Computing Toolbox™ ThreadPool.This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment. GPU Arrays Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox). Distributed Arrays Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox). Version HistoryIntroduced in R2015a |