Vectorization of an arrayfun problem
Show older comments
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.
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!