I am trying to understand how to pass functions to varfun, which I suppose applies to arrayfun, cellfun etc.
Reading the helpf
In the first code snippet, mean is a (named) function, and @mean is a function handle to that function. You could equivalently use
f = @mean;
varfun(f, dataTable)
In the second case, when you define
mymean = @(x){sum(x)/length(x)};
the @(x){sum(x)/length(x)}part is an anonymous function, and the variable mymean is again a function handle to that (anonymous) function. So you need to use varfun(mymean, dataTable), not varfun(@mymean, dataTable).
So, the @ sign is being used in two different ways, although in both cases it produces a function handle: