我发现了一个例子,2007年MATLAB中,cellfun并arrayfun几乎可以互换使用:
>> cellfun(@(c) c, {'one' 'two' 'three'}, 'uniformoutput', 0)
% ans =
% 'one' 'two' 'three'
>> arrayfun(@(c) c, {'one' 'two' 'three'})
% ans =
% 'one' 'two' 'three'
Run Code Online (Sandbox Code Playgroud)
我也可以想到一个有效的例子,arrayfun但cellfun不是:
>> arrayfun(@(c) c, [1 2 3])
% ans =
% 1 2 3
>> cellfun(@(c) c, [1 2 3])
% ??? Error using ==> cellfun
% Input #2 expected to be a cell array, was double instead.
Run Code Online (Sandbox Code Playgroud)
我的问题是:有没有可行的情况cellfun但却arrayfun没有?如果是,请举例.如果不是,为什么 …