Matrix indexing using a vector
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Fabio Pasquarella
le 30 Mai 2016
Réponse apportée : Andrei Bobrov
le 30 Mai 2016
Let's say I have a vector b where each row correspond to an index for each row in the matrix A. I want to assign 1 to these elements, like in the matrix C, without loops. Thank you
A = zeros(4,3);
b = [2;1;2;3];
C = [0 1 0; 1 0 0; 0 1 0; 0 0 1]
0 commentaires
Réponse acceptée
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!