replace nonzero element of matrix with vector
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello I have matrix A:
A=[2 3 0 0;6 0 2 4;1 2 0 7]
I want to replace nonzero element of this matrix with matrix B respectively. matrix B is:
B=[70;11;111;8;7;22;15;64]
Thank you.
2 commentaires
Stephen23
le 19 Nov 2015
Modifié(e) : Stephen23
le 19 Nov 2015
@fatema saba: you do not need to use find, it just makes the code slower and more complicated without any benefit. It is better to use logical indexing, as per Walter Roberson's answer.
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!