Create the matrix with some limits

How should I do if I want to build a matrix like [1 2 1 2 ......](which length is 10) with two instructions.And one of the instructions is n=10.
I do'nt know how to do it without 'if' and 'for'.

 採用された回答

Andrei Bobrov
Andrei Bobrov 2019 年 2 月 27 日

0 投票

kron(ones(1,10),1:2)

1 件のコメント

Lee hsuan
Lee hsuan 2019 年 2 月 27 日
Thank you. I forgot this function.Love you dude.

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

その他の回答 (1 件)

KSSV
KSSV 2019 年 2 月 27 日

0 投票

p = [1 2] ;
n = 10 ;
q = repmat(p,1,n)

1 件のコメント

Lee hsuan
Lee hsuan 2019 年 2 月 27 日
I think this is the three-instructions solution.If l'm wrong ,please tell me. Thank you.

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

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

タグ

質問済み:

2019 年 2 月 27 日

コメント済み:

2019 年 2 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by