Replicate matrix elements without for loop

2 次查看(过去 30 天)
I am trying to take the matrix
base =[1 2; 3 4]
and replicate the elements to give
expn = [ 1 1 2 2; 1 1 2 2; 3 3 4 4; 3 3 4 4]
without using for loops. I would like to use repmat but not sure how to do that elementwise.

采纳的回答

David Hill
David Hill 2022-11-22
base =[1 2; 3 4];
repelem(base,2,2)
ans = 4×4
1 1 2 2 1 1 2 2 3 3 4 4 3 3 4 4

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by