相关疑难解决方法(0)

在MATLAB中,cellfun是否总是可以用arrayfun替换?

我发现了一个例子,2007年MATLAB中,cellfunarrayfun几乎可以互换使用:

>> 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)

我也可以想到一个有效的例子,arrayfuncellfun不是:

>> 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没有?如果是,请举例.如果不是,为什么 …

arrays matlab

2
推荐指数
1
解决办法
3115
查看次数

标签 统计

arrays ×1

matlab ×1