0

I want to do a simple thing with matlab but I don't find how I can do that...

So, a little example is more explicit than lots of sentences...

I have a matrix :

1 2 3
4 5 6

And I want to have the same matrix twice bigger with same proportion. I want to have :

1 1 2 2 3 3
1 1 2 2 3 3
4 4 5 5 6 6
4 4 5 5 6 6

Someone can help me ?

Thanks !

Joachim Isaksson
  • 176,943
  • 25
  • 281
  • 294
  • Fairly comprehensive answers here: http://stackoverflow.com/questions/14615305/a-similar-function-to-rs-rep-in-matlab/14620028#14620028 – Dan Jun 30 '14 at 13:03
  • another duplicate, two days before the one above: http://stackoverflow.com/questions/14576007/how-to-double-the-size-of-a-matrix-and-propagate-its-elements-in-matlab/14576141#14576141 – bla Jun 30 '14 at 16:02

1 Answers1

0

I always use reshape() and repmat() to manipulate matrices and vectors. Maybe there are other solutions. In your case this would be:

test1 = 1:6;
test2 = repmat(test1, 2, 1);
test3 = reshape(test2, 1, 6*2);

EDIT: Ah okay, now that your question has been formatted it has changed and my solution doesn't hold anymore but a link has already been attached. There your problem is solved with kron(). Sorry guys, but the question changed after I posted my answer ;)

13aumi
  • 169
  • 5