matlab中出现??? Undefined command/function 'arrayfun'.是为什么

代码是 f=@(x) x.^3+sqrt(402)*x.^2+(402/3-3)*x-sqrt(402)*(1-402/27);
x=[-9 -8];
arrayfun(fsolve(f,x),x)
结果出现
Optimization terminated: first-order optimality is less than options.TolFun.
??? Undefined command/function 'arrayfun'.

第1个回答  2022-11-17
arrayfun函数有两个输入,第一个是函数柄,第二个是数组,因此,上面和序可改为:
f=@(x) x.^3+sqrt(402)*x.^2+(402/3-3)*x-sqrt(402)*(1-402/27);
x=[-9 -8];
arrayfun(f,fsolve(f,x))
运行结果是:
ans =
1.0e-09 *
-0.0002 -0.7859
说明这两个数代入得到的结果都近于0.
相似回答
大家正在搜