How to create an array with repeating values of a vector

how can I create a matrix based on the vector v = [12.56, 65.23, 5.67], which is repeated 20 times? So that the matrix M look like:
M = [12.56 65.23 5.67 ; 12.56 65.23 5.67 ; 12.56 65.23 5.67; .... ; 12.56 65.23 5.67] ?
Thanks a lot.
Harry

 採用された回答

Stephen23
Stephen23 2020 年 4 月 7 日
編集済み: Stephen23 2020 年 4 月 7 日

1 投票

m = repmat(v,20,1)
or
m = v(ones(1,20),:)
or
m = ones(20,1)*v
or
m = zeros(20,1)+v % requires >=R2016b
or
[~,X] = ndgrid(1:20,1:3);
m = v(X)
or ...

その他の回答 (0 件)

カテゴリ

製品

リリース

R2019b

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by