Vectorization dividing row by their maximum.

5 vues (au cours des 30 derniers jours)
Aravin
Aravin le 18 Avr 2015
Commenté : Jameel Hassan le 4 Oct 2019
*Dear All,
Let say I have M = magic(10); Now I want to divide each element of the matrix by the maximum element row wise.
For example, I can get max in rows by
m = max(M, [],2);
Now this is column matrix having same number of rows as M. Now I want to divide each row of M by the row value of m .*

Réponse acceptée

Star Strider
Star Strider le 18 Avr 2015
This looks like it works:
M = magic(10);
m = max(M, [],2);
Result = bsxfun(@rdivide, M, m);
  1 commentaire
Jameel Hassan
Jameel Hassan le 4 Oct 2019
Why not just use
Result = M./m;

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical 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!

Translated by