R言語のapply関数に相当するものはMatlabにあるか

bsxfunやnum2cellを工夫して使うのが1つの方法のようだ。

function ret = apply_rs1( imat, margin, ifunc)
%R-like apply function but be careful, the output may be different from that of R.
%
% Ex.
% apply_rs1(m, 1, @(x) x - mean(x)) ... Equivalent to bsxfun(@minus, m, mean(m))
% apply_rs1(m, 2, @(x) x - mean(x))
 
    ret = cell2mat(cellfun(@(x) ifunc(x), num2cell(imat, margin), 'UniformOutput', false));
 
end

もっともmeanなら、自動的に列ごとの平均を出してくれるようだが。ちなみに、@(x) ifunc(x)のところは、少なくともMatlab 2008bでは、@ifuncにするとエラーになった。