PDA

查看完整版本 : [求助]新手问题


simonspringzz
2008-12-06, 10:14
计算f(x)=sinx+3的最小值
编写程序
function f=myfun(x);
syms x;
f=sin(x)+3;

之后运行
x0=2; %以x0为初始点
[x,fval]=fminsearch(@myfun,x0)


运行却提示出错:
??? Conversion to double from sym is not possible.

Error in ==> D:\MATLAB6p5\toolbox\matlab\funfun\fminsearch.m
On line 125 ==> fv(:,1) = feval(funfcn,x,varargin{:});

刚学matlab,还很不熟悉,望高手指教!