matlab中fminunc函数使用方法,科学网—MATLAB中的两个常用数值优化函数fminsearch()和fminunc() - 王福昌的博文...

MATLAB中提供了两个命令:fminsearch(),fminunc(),

x = fminsearch(Fun,x0)

[x,fval,flag,out] = fminsearch(Fun,x0,opt,p1,p1,...)

fminunc 与 fminsearch 用法相同。

测试版本 MATLAB 2016b.

例1 已知 $z = f(x,y) = (x^2-x)\text{e}^{-x^2-y^2-xy}$ ,求其最小值并显示求解过程。

>> f = @(x)(x(1)^2-x(1))*exp(-x(1)^2-x(2)^2-x(1)*x(2));x0 = [2;1];

>> [x,b,c,d] = fminsearch(f,x0)

x =

28.8538

3.3448

b =

0

c =

1

d =

包含以下字段的 struct:

iterations: 30

funcCount: 94

algorithm: 'Nelder-Mead simplex direct search'

message: '优化已终止:…'

>>  [x,b,c,d] = fminunc(f,x0)

警告: Gradient must be provided for trust-region algorithm; using quasi-newton

algorithm instead.

> In fminunc (line 395)

Local minimum found.

Optimization completed because the size of the gradient is less than

the default value of the optimality tolerance.

x =

2.9047

1.9353

b =

1.0247e-07

c =

1

d =

包含以下字段的 struct:

iterations: 13

funcCount: 45

stepsize: 0.0769

lssteplength: 1

firstorderopt: 7.0454e-07

algorithm: 'quasi-newton'

message: 'Local minimum found.…'

转载本文请联系原作者获取授权,同时请注明本文来自王福昌科学网博客。

链接地址:http://blog.sciencenet.cn/blog-292361-1074987.html

上一篇:无约束最优化问题求解

下一篇:MATLAB优化工具箱遗传算法函数ga()用法示例

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值