make matrix for given vector ( better method)

1 次查看(过去 30 天)
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);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!