Scale Matrix Dimensions by Factor

4 visualizaciones (últimos 30 días)
Philip
Philip el 16 de Nov. de 2018
Comentada: Philip el 16 de Nov. de 2018
I have a matrix that needs to be scaled in the horizontal, copying each row.
Ex:
[1 2 3]
[4 5 6]
Scale Columns only by Factor 3
[1 1 1 2 2 2 3 3 3]
[4 4 4 5 5 5 6 6 6]
How can I write a simple loop to perform this. Thanks!

Respuesta aceptada

Bruno Luong
Bruno Luong el 16 de Nov. de 2018
>> repelem([1 2 3],3)
ans =
1 1 1 2 2 2 3 3 3
>>
  4 comentarios
Bruno Luong
Bruno Luong el 16 de Nov. de 2018
I think I understand now your incorrect MATLAB notation
>> repelem([1 2 3; 4 5 6],1,3)
ans =
1 1 1 2 2 2 3 3 3
4 4 4 5 5 5 6 6 6
>>
Philip
Philip el 16 de Nov. de 2018
Thanks!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Productos


Versión

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by