Matlab arrayfun的奇怪错误

Matlab arrayfun的奇怪错误,matlab,Matlab,我有以下代码行: sample_density=[4;5]; Grid=arrayfun(@(x)linspace(0,2*pi,x),sample_density,'UniformOutput','off'); 匿名函数@(x)linspace(0,2*pi,x)工作正常。因此,使用循环手动执行代码是可行的。但运行上述代码会导致以下错误: Error using arrayfun All of the input arguments must be of the same size and

我有以下代码行:

sample_density=[4;5];
Grid=arrayfun(@(x)linspace(0,2*pi,x),sample_density,'UniformOutput','off');
匿名函数
@(x)linspace(0,2*pi,x)
工作正常。因此,使用循环手动执行代码是可行的。但运行上述代码会导致以下错误:

Error using arrayfun
All of the input arguments must be of the same size and shape.
Previous inputs had size 2 in dimension 1. Input #3 has size 1
我不明白这个信息的意思。似乎没有任何方法可以找到消息被触发的位置。有人知道“输入3”可能是什么吗


从表面上看,消息中描述的情况根本不是这样。为什么代码不起作用?

您将
'UniformOutput'
的名称-值对搞错了

参数是布尔值(
true
false
),而不是字符串
'on'
'off'
。以下语法应该可以工作:

sample_density=[4;5];
Grid=arrayfun(@(x)linspace(0,2*pi,x),sample_density,'UniformOutput',false);