Reputation: 6882
Imagine a matrix :
a = 4 2 8 9
I need to repeat it n times. If n = 3, the result is :
n = 3
a = 4 4 4 2 2 2 8 8 8 9 9 9
Upvotes: 0
Views: 578
Reputation: 159
try using the kron function, newMatrix = kron(a,ones(1,4))
Reputation: 9317
You can try:
n = 3; reshape(repmat(a', n, 1), numel(a)*n, 1)
Upvotes: 7