I have a matrix like this
1 2 3 4
2 3 4 5
3 4 5 6
is there any function that makes rows n times and columns m times in matlab i mean for example for n=2 and m=3 the result be:
1 1 1 2 2 2 3 3 3 4 4 4
1 1 1 2 2 2 3 3 3 4 4 4
2 2 2 3 3 3 4 4 4 5 5 5
2 2 2 3 3 3 4 4 4 5 5 5
3 3 3 4 4 4 5 5 5 6 6 6
3 3 3 4 4 4 5 5 5 6 6 6
thanks
You can use the kronecker product:
A=[1 2 3 4;5 6 7 8;9 10 11 12];
kron(A,ones(2,3))
ans =
1 1 1 2 2 2 3 3 3 4 4 4
1 1 1 2 2 2 3 3 3 4 4 4
5 5 5 6 6 6 7 7 7 8 8 8
5 5 5 6 6 6 7 7 7 8 8 8
9 9 9 10 10 10 11 11 11 12 12 12
9 9 9 10 10 10 11 11 11 12 12 12
For more information, you can look on wikipedia:
http://en.wikipedia.org/wiki/Kronecker_product
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With