multiply numbers in a table

Assume the following numbers in a table
1
2
3
4
How can I multiply them in the following manner:
1
1
1
1
2
2
2
2
3
3
3
3
4
4
4
4
thanks

1 comentario

John D'Errico
John D'Errico el 14 de Nov. de 2014
You mean to replicate them, not multiply them. Multiplication is an arithmetic operation as I recall.

Iniciar sesión para comentar.

 Respuesta aceptada

per isakson
per isakson el 14 de Nov. de 2014

1 voto

Try
x = [1;2;3;4];
reshape( repmat( transpose(x), [4,1]), [], 1 )

Más respuestas (3)

Matt J
Matt J el 14 de Nov. de 2014

1 voto

Another way,
x = [1;2;3;4];
result = x( ceil((1:length(x)*4)/4) );
Matt J
Matt J el 14 de Nov. de 2014

1 voto

x=1:4;
result=ones(4,1)*x;
result=result(:);

Categorías

Etiquetas

Preguntada:

AA
el 14 de Nov. de 2014

Respondida:

el 14 de Nov. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by