matrix multiple line should be the same

1 次查看(过去 30 天)
TheDice
TheDice 2021-4-21
回答: DGM 2021-4-21
hello i want to write a matrix in which the first two rows are equal and the third and fourth are also equal. so this is how it should look:
x = 1 2 3 4 5
1 2 3 4 5
6 7 8 9 10
6 7 8 9 10

回答(1 个)

DGM
DGM 2021-4-21
x = [1 2 3 4 5;
6 7 8 9 10]
% replicate elements in 2x1 blocks
xx = repelem(x,2,1)
gives
xx =
1 2 3 4 5
1 2 3 4 5
6 7 8 9 10
6 7 8 9 10
for replicating columns, just use
% replicate elements in 1x2 blocks
xx = repelem(x,1,2)

类别

Help CenterFile Exchange 中查找有关 Operating on Diagonal Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by