If you can do with a single function g
that returns the cumulative sum for scalar x
:
g = @(x) cumsum(cellfun(@(y) y(x), f))
Example:
f{1} = @(x) x;
f{2} = @(x) x^2;
f{3} = @(x) x^3;
g = @(x) cumsum(cellfun(@(y) y(x), f))
g(3)
ans =
3 12 39
Explanation: cellfun
takes each component function f{1}
, f{2}
etc and returns the result of evaluating that function at x
. The result for each function should be scalar. The cumulative sum of all those values is then computed.