matlab 求函数最小值
>>symstreal>>x=[t-1,t,t+2]';>>y=@(t)x'*x;>>fminsearch(y,0)程序运行出错Thefollowingerroroccu...
>> syms t real
>> x=[t-1,t,t+2]';
>> y=@(t)x'*x;
>> fminsearch(y,0)
程序运行出错
The following error occurred converting from sym to double:
Error using mupadmex
Error in MuPAD command: DOUBLE cannot convert the input expression into a
double array.
If the input expression contains a symbolic variable, use the VPA function
instead.
Error in fminsearch (line 191)
fv(:,1) = funfcn(x,varargin{:}); 展开
>> x=[t-1,t,t+2]';
>> y=@(t)x'*x;
>> fminsearch(y,0)
程序运行出错
The following error occurred converting from sym to double:
Error using mupadmex
Error in MuPAD command: DOUBLE cannot convert the input expression into a
double array.
If the input expression contains a symbolic variable, use the VPA function
instead.
Error in fminsearch (line 191)
fv(:,1) = funfcn(x,varargin{:}); 展开
1个回答
展开全部
syms t real
x=[t-1,t,t+2]';
y=x'*x;
y=inline(y);
fminsearch(y,0)
应该是这样的
x=[t-1,t,t+2]';
y=x'*x;
y=inline(y);
fminsearch(y,0)
应该是这样的
追问
已经搞定了,这样写就行了
>> syms t real
>> x=[t-1,t,t+2]';
>> y=@(t)subs(x'*x);
>> fminsearch(y,0)
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询