make matrix for given vector ( better method)

3 ビュー (過去 30 日間)
JaeSung Choi
JaeSung Choi 2017 年 11 月 21 日
コメント済み: JaeSung Choi 2017 年 11 月 21 日
for given vector x = [x1 x2 x3 x4 x5]
I want to make square matrix y = [x; x; x; x; x]
actually I can make it using
--------------------
for i = 1 : 5
y(i,:) = x
end
--------------------
but i have to do such calculation many times, so I want even fast method!
Please help me!!

採用された回答

Birdman
Birdman 2017 年 11 月 21 日
編集済み: Birdman 2017 年 11 月 21 日
If x is a column vector:
Y=repmat(x,1,size(x,1));
If x is a row vector:
Y=repmat(x,size(x,2),1);
  1 件のコメント
JaeSung Choi
JaeSung Choi 2017 年 11 月 21 日
really thanks your answer saved me from waiting!!

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

その他の回答 (0 件)

カテゴリ

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!