MATLAB: Summation of Function Handle Cells

cellsfunction handleMATLABsum

Hello.
I am trying to sum up each individual cell that is produced by a function handle in a for loop that runs from.
My handle looks like this:
for a = 1 : 11;
f{a} = @(u)1
for b = setdiff(1:11, a);
f{a} = @(u)1.*G.*mass_a.*mass_b.*r./(norm_r^3)
%need to sum up all 11 cells produced here
end
end
The function handle spits out something like this (I have only put 2 cells, there are 11):
{@(u)1.*G.*mass_a.*mass_b.*r./(norm_r^3)} {@(u)1.*G.*mass_a.*mass_b.*r./(norm_r^3)}
I need to sum all of the cells from above up.
It seems like the sum function on matlab does not work. I have seen a couple of instances of loops being used, but can't seem to be able to apply them correctly.
Thanks

Best Answer

fsum = @(x) sum(cellfun(@(F) F(x), f));