How can I generate a matrix with the same vector in all the lines?
조회 수: 43 (최근 30일)
이전 댓글 표시
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
채택된 답변
추가 답변 (3개)
Matt Fig
2012년 11월 13일
I think this is what REPMAT probably is doing behind the scenes:
V = 1:3;
M = V(ones(1,4),:)
댓글 수: 0
Walter Roberson
2012년 11월 13일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!