How to set elements in 2D matrix based on a given vector?
Mostrar comentarios más antiguos
Hi,
I have a zeros array [0 0 0;0 0 0;0 0 0] and a vector [3;1;2]. I want to have an array [0 0 1;1 0 0;0 1 0]. Is it possible to do that using only indexing and slicing instead of for-loop? Thanks.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Matrix Indexing 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!