-2

I this matrix:

A = [2 3 4 6 7 8 9 1 2];

I need to change that matrix into:

B = [2 3 4 6 7 8 9 1 2;
     2 3 4 6 7 8 9 1 2;
     2 3 4 6 7 8 9 1 2]

the output will be:

B =

 2     3     4     6     7     8     9     1     2
 2     3     4     6     7     8     9     1     2
 2     3     4     6     7     8     9     1     2

Thank you so much...

Joshua
  • 40,822
  • 8
  • 72
  • 132
8727
  • 73
  • 8
  • Possible duplicate of [Matlab: create matrix whose rows are identical vector. Use repmat() or multiply by ones()](https://stackoverflow.com/questions/32797649/matlab-create-matrix-whose-rows-are-identical-vector-use-repmat-or-multiply) – Cris Luengo Sep 07 '18 at 17:42

1 Answers1

3

repmat and repelem are used for repeating the copies of an array. For your case, you can use either of these as: repmat(A,3,1) or repelem(A,3,1)

Sardar Usama
  • 19,536
  • 9
  • 36
  • 58