cellfun is just like looping through the cell matrix and
executing specified function separately on each cell.
It's usually faster than doing the same thing explicitly
in loop, but the basic difference is that its easy to
write and read - its immediately clear what the call is
doing. But you could just as well write the loop yourself.

In your specific case you could use cellfun this way:

mean_a = mean(cellfun(@(x) mean(x(:)), a));

If you have thousands of cells and you want to do something
to each of them you either use a loop or a cellfun
BTW: @(x) means that you want the content of each cell
to be understood as x so that mean(x(:)) gives you what
you want - mean of the whole matrix content of the cell.

Answer from mmagnuski on Stack Overflow
🌐
MathWorks
mathworks.com › matlab › language fundamentals › data types › cell arrays
cellfun - Apply function to each cell in cell array - MATLAB
For example, to use the sum function, which requires a compile-time constant for the second argument dimension, use out = cellfun(@(x) sum(x, 2), xIn). Here, 2 is the hard-coded compile-time constant representing the dimension. This function fully supports thread-based environments.
🌐
Northwestern University
ece.northwestern.edu › local-apps › matlabhelp › techdoc › ref › cellfun.html
cellfun (MATLAB Functions)
D = cellfun('isreal',C) D = 1 1 1 0 1 1 len = cellfun('length',C) len = 2 4 1 1 1 3 isdbl = cellfun('isclass',C,'double') isdbl = 1 0 1 1 1 1
Discussions

Cellfun... shall I use it?
Cellfun and arrayfun are generally much slower than simple loop. Their main usecase is to simplify code where performance is not an issue. Better alternative is vectorization which is both fast and concise. (For gpuArrays, arrayfun is faster but that is a special case). More on reddit.com
🌐 r/matlab
14
1
May 8, 2023
Calling a function option using cellfun
The anonymous function in Guillaume's ... to cellfun. The anonymous function does define one input argument named x. ... If you are asking about that input argument, then you can rename it if you want to. What is the imperative for this? ... Your question shows a cell array named C. ... https://www.mathworks.com/matlabcentral/answers/3... More on mathworks.com
🌐 mathworks.com
2
1
December 20, 2017
Explanation of cellfun()
I have a rather stupid question I think, but I do not understand a specific call of the cellfun(). My question came up when I was working with the MATLAB example: Similarity-Based Remaining Useful Life Estimation. More on mathworks.com
🌐 mathworks.com
1
0
May 20, 2020
image processing - How do I apply a function with multiple parameters using `cellfun` (MATLAB)? - Stack Overflow
Recently came across this problem, ... in cellfun, Matlab doesn't. Calling an anonymous function has more overhead than calling the function directly (although Matlab is not nearly as bad as Octave in that regard) so I found passing the parameter as a cell array to be a bit faster, shown here with a simple example... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Stack Overflow
stackoverflow.com › questions › 60878133 › matlab-using-get-in-cellfun-for-a-cell-array-of-objects
MATLAB: Using get in cellfun for a cell array of objects - Stack Overflow
pos = cellfun( @(obj) getattr( obj, 2 ), myCellOfObjects, 'uni', 0 ); By specifying 'uni', 0, the output doesn't have to be scalar and will be put into a cell array. This is useful when, for example, you have a multi-element array for your position.
Find elsewhere
🌐
OLXTOTO
matlabgeeks.com › home › olxtoto › olxtoto * daftar akun bandar toto macau anti boncos bosku
Computation using cellfun
February 11, 2024 - OLXTOTO mempersembahkan Daftar Akun Bandar Toto Macau Anti Boncos Bosku, solusi terbaik bagi para penggemar taruhan yang ingin meraih kemenangan.
Rating: 100/100 ​ - ​ 355K votes
🌐
Exponenta
docs.exponenta.ru › matlab › language fundamentals › data types › cell arrays
cellfun
Создайте сокращения от имен в массиве строк с помощью cellfun.
🌐
RunMat
runmat.com › docs › reference › cellfun
cellfun | MATLAB Language Function Reference - RunMat.com
February 25, 2026 - cells = {1, 'two', 3}; eh = @(err, value) sprintf('%s @ %d', err.identifier, err.index); results = cellfun(@(x) x + 1, cells, 'UniformOutput', false, 'ErrorHandler', eh) ... No. The builtin reads the cell contents, calls the supplied function, ...
🌐
MathWorks
mathworks.com › matlabcentral › answers › 811680-understanding-the-structfun-or-cellfun-commands
Understanding the structfun() or cellfun() commands - MATLAB Answers - MATLAB Central
April 23, 2021 - For example: A = {Files.name}; B = cellfun(??,A); % I do not know what to put here · I want to understand how to use an arbitrary function inside the cellfun() command to be able to use them in the future.
🌐
MathWorks
mathworks.com › matlabcentral › answers › 332158-cellfun-to-extract-arrays-from-multi-dimensional-cell
Cellfun to extract arrays from multi-dimensional cell - MATLAB Answers - MATLAB Central
March 27, 2017 - Imagine I have a 2-d cell, each cell element is a m by n matrix, I apply SVD on each element such that they are decomposed into left singular vectors, singular values and right singular vectors.