Is there any way to retrieve the index of the element on which a function called by cellfun, arrayfun or spfun acts? (i.e
cellfun
arrayfun
spfun
You can create a sparse matrix with linear_index filling instead of values.
Create A:
A
A(find(S))=find(S)
Then use A and S without spfun, e.g.: A.*S. This runs very fast.
S
A.*S