Can this be done? Basically, I have a struct array val (contains a list of my custom structure) and I want to multiply all the elements together using custom multiply function Multiply and I don't want to use loop.
I tried to use accumarray(indx, val', [1 1], @Multiply)
with indx=ones(lengths(val), 2)
but this doesn't work (at least for Octave 3.4.3). When execute, inside my C=Multiply(A,B)
function, A is passed the whole struct array, and B is empty instead of A is the first element of the array and B is the second element as in normal case.
Hope I made myself clear here. Thanks
I am not sure what you wanted to do. I have worked out some code related to what you expected:
It is the first time I use the accumarray function, so maybe I am misunderstanding what you needed. Hope I could help,