Expand 1-D array to 2-D matrix using 'ones' function and colon ':'
Mostrar comentarios más antiguos
Example:
matrixA = 6:10;
matrixA = matrixA(ones(1,5), :);
or:
matrixB = (6:10)';
matrixB = matrixB(:, ones(1,5));
My Question:
What's going on here? I just don't get it. Is there any reference on this "exotic" usage? Many thanks for any inputs!
Respuesta aceptada
Más respuestas (2)
Oleg Komarov
el 5 de Sept. de 2011
matrixA = matrixA(ones(1,5), :)
select all elements from row one 5 times.
matrixB = matrixB(:, ones(1,5));
select all elements from column one 5 times.
Edwin
el 6 de Sept. de 2011
Categorías
Más información sobre Whos en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!