Given a combining function, a cell array, and an initial value, accumulate the result.
For example,
accumcell(@plus,{1,2,3,4},0)
should return 10, while
accumcell(@times,{1,2,3,4},1)
should return 24.
The elements of C should be such that the combining function can apply to them without generating an error (all the same size, for example).
Solution Stats
Problem Comments
2 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers48
Suggested Problems
-
Find all elements less than 0 or greater than 10 and replace them with NaN
15805 Solvers
-
Project Euler: Problem 10, Sum of Primes
2122 Solvers
-
Who knows the last digit of pi?
692 Solvers
-
Create a matrix X, where each column is a shifted copy of the vector v
226 Solvers
-
Find Index of maximum Value and maximum Value of a vector
168 Solvers
More from this Author11
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
I'm hoping there is a built-in function I don't know about that solves this problem. Perhaps accumarray?
Nice