matlab中fminunc函数使用方法,科学网—MATLAB中的两个常用数值优化函数fminsearch()和fminunc()

阅读: 评论:0

matlab中fminunc函数使用方法,科学网—MATLAB中的两个常用数值优化函数fminsearch()和fminunc()

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.…'

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

链接地址:.html

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

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

本文发布于:2024-02-01 18:54:26,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170678486538739.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:函数   数值   使用方法   常用   两个
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23