make matrix for given vector ( better method)

1 vue (au cours des 30 derniers jours)
JaeSung Choi
JaeSung Choi le 21 Nov 2017
Commenté : JaeSung Choi le 21 Nov 2017
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!!

Réponse acceptée

Birdman
Birdman le 21 Nov 2017
Modifié(e) : Birdman le 21 Nov 2017
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 commentaire
JaeSung Choi
JaeSung Choi le 21 Nov 2017
really thanks your answer saved me from waiting!!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!