How can I generate a matrix with the same vector in all the lines?
43 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I'd like to generate a matrix with the same vector n times. What I can choose. For example:
A= [ 1 2 3; 1 2 3; 1 2 3; .....n times......; 1 2 3]
Thank You
0 commentaires
Réponse acceptée
Plus de réponses (3)
Matt Fig
le 13 Nov 2012
I think this is what REPMAT probably is doing behind the scenes:
V = 1:3;
M = V(ones(1,4),:)
0 commentaires
Walter Roberson
le 13 Nov 2012
t = 1:3;
A = t(ones(n,1), :); %what repmat will do internally so faster than repmat
or
kron(1:3, ones(n,1)); %slower than repmat but kron() has some good uses
0 commentaires
Voir également
Catégories
En savoir plus sur Multidimensional Arrays 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!