Vectorization of an arrayfun problem
Afficher commentaires plus anciens
Consider a AxB matrix M with A>1 & B>1. I need to perform the following operation:
Output=arrayfun(@(input) sum(p_matrix.*max(input,M),'all'), M);
For each 1x1 entry of M (input), max(input,M) returns a AxB matrix with the greatest numbers between "input" and each entry of M, element-wise. The result is multiplied by AxB p_matrix, element-wise, and its elements are summed up. The result is saved in the corresponding entry of Output, a AxB matrix as well.
Arrayfun slowly loops over each element of M, one by one. Is there any way to build a vectorized version of this command?
Thanks sincerely.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!