VERY simple question about adding 2 matrices

2 vues (au cours des 30 derniers jours)
Mohsen
Mohsen le 17 Mar 2014
Commenté : Mohsen le 17 Mar 2014
Matrix A and B have the same size: 512 x 512 x 105.
I want each element of matrix A to be equal to the corresponding element in matrix B when that element in matrix B is greater than zero.
How can I write this without a for loop?
Thank you very much!!

Réponse acceptée

Walter Roberson
Walter Roberson le 17 Mar 2014
A(B>0) = B(B>0);

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by