array manipulation such as [ 1 2 5 7 3 .... ] --> [ 1 1 1 ... 2 2 2 ... 5 5 5 ... 7 7 7 ... 3 3 3 ... .... ].

조회 수: 11 (최근 30일)
JK
JK 2017년 9월 17일
답변: Jan 2017년 9월 17일
Using
A = [ 1 2 5 7 3 .... ],
I would like to create
B = [ 1 1 1 ... 2 2 2 ... 5 5 5 ... 7 7 7 ... 3 3 3 ... .... ]
Can you please show me a way to do that? Thanks.

채택된 답변

Jan
Jan 2017년 9월 17일

추가 답변 (1개)

michio
michio 2017년 9월 17일
A = [ 1 2 5 7 3];
tmp = repmat(A,[3,1]);
B = tmp(:)';

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by