matrix multiple line should be the same

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 件のコメント

TheDice
TheDice 2021 年 4 月 21 日
or even better:
1 1 6 6
2 2 7 7
3 3 8 8
4 4 9 9
5 5 10 10

サインインしてコメントする。

回答 (1 件)

DGM
DGM 2021 年 4 月 21 日

0 投票

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)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

質問済み:

2021 年 4 月 21 日

回答済み:

DGM
2021 年 4 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by