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

1 次查看(过去 30 天)
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 中查找有关 Multidimensional Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by