how to create a vector A [1,1,2,2,3,3] from a vector B [1,2,3]

조회 수: 17 (최근 30일)
Imène Daoud
Imène Daoud 2021년 7월 1일
편집: John D'Errico 2021년 7월 1일
how to create a vector A [1,1,2,2,3,3] from a vector B[1,2,3] using a function

답변 (1개)

John D'Errico
John D'Errico 2021년 7월 1일
편집: John D'Errico 2021년 7월 1일
help repelem
REPELEM Replicate elements of an array. U = REPELEM(V,N), where V is a vector, returns a vector of repeated elements of V. - If N is a scalar, each element of V is repeated N times. - If N is a vector, element V(i) is repeated N(i) times. N must be the same length as V. B = repelem(A, R1, ..., RN), returns an array with each element of A repeated according to R1, ..., RN. Each R1, ..., RN must either be a scalar or a vector with the same length as A in the corresponding dimension. Example: If A = [1 2; 3 4], then repelem(A, 2, 3) returns a matrix containing a 2-by-3 block of each element of A: [1 1 1 2 2 2; ... 1 1 1 2 2 2; ... 3 3 3 4 4 4; ... 3 3 3 4 4 4]. See also REPMAT, BSXFUN, MESHGRID. Documentation for repelem doc repelem Other functions named repelem codistributed/repelem symfun/repelem tall/repelem gpuArray/repelem tabular/repelem

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by