我刚从一位同事那里收到一个脚本,他的第一行是这样的:
VonMisesModel=fittype(@(A,k,base,peakloc,x) (base + A*exp(k*cos((pi/180)*(x-peakloc)))/(2*besseli(0,k)*pi)),'independent','x');
他用这个脚本做了很多处理,所以我想这行代码对他有用。
但是,当我调用它时,我收到以下错误:
>> VonMisesModel=fittype(@(A,k,base,peakloc,x) (base + A*exp(k*cos((pi/180)*(x-peakloc)))/(2*besseli(0,k)*pi)),'independent','x');
Error using strcmp
The number of rows of the string matrix must match the number of elements in the cell.
Error in cell/ismember (line 38)
match = strcmp(a,b);
Error in fittype>iTestAnonymousFunctionArgumentOrder (line 786)
[~, coefficientLocations] = ismember( obj.coeff, arguments );
Error in fittype>iCreateFromAnonymousFunction (line 533)
iTestAnonymousFunctionArgumentOrder( obj, theFcn )
Error in fittype>iCreateFittype (line 355)
obj = iCreateFromAnonymousFunction( obj, varargin{:} );
Error in fittype (line 328)
obj = iCreateFittype( obj, varargin{:} );
我想重申,这是独立脚本中的第一行。在调用此行之前不会进行任何处理。
这个错误对我来说似乎并不直观。我对可能导致它的原因的猜测没有找到解决方案。有谁知道为什么会出现这个错误?
编辑
函数的定义fittype
似乎随着时间而改变。
当我使用高于matlab-2012a
.
但是,当我使用matlab-2012a
.
我的 2012 年之前的matlab
发行版根本不包含该功能fittype
。
为了让这个脚本中的其他函数能够正常工作,我需要调用这个调用来fittype
使用新(er)版本的 Matlab。如果可以,请让我知道如何重新安排通话以防止出现错误。