repeating numbers in matrix

15 ビュー (過去 30 日間)
vinayak hungund
vinayak hungund 2015 年 7 月 9 日
回答済み: Check Codes 2021 年 1 月 4 日
I need to generate a input variation in the form
% For wxample
col1 :2 4 6 2 4 6 2 4 6 2 4 6
col2 :1 1 1 1 1 1 2 2 2 2 2 2
col2 :5 5 5 5 5 5 5 5 5 5 5 5
is there any shorter way to do it without looping.

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 7 月 9 日
編集済み: Azzi Abdelmalek 2015 年 7 月 9 日
col1=repmat(2:2:6,1,3)
col2=reshape(repmat(1:2,6,1),1,[])
col3=5*ones(1,12)
Read the documentation
doc repmat
doc reshape
  1 件のコメント
vinayak hungund
vinayak hungund 2015 年 7 月 9 日
Super ! Thank you.

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

その他の回答 (1 件)

Check Codes
Check Codes 2021 年 1 月 4 日
P=[6 9 13 31 18]; position=5; Q=[285 65]; /Period matrix number of period =3;
o/p part: out_put =[6 9 13 31 285 65 285 65 285 85 18];

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by