美文网首页MATLAB
matlab - fminunc 函数

matlab - fminunc 函数

作者: 庵下桃花仙 | 来源:发表于2018-05-24 16:18 被阅读20次

功能

找到最小的无约束多变量函数

min f(x)
x

where f(x) is a function that returns a scalar(标量).
x is a vector or a matrix;

语法

x = fminunc(fun,x0)
x = fminunc(fun,x0,options)
x = fminunc(problem)
[x,fval] = fminunc(___)
[x,fval,exitflag,output] = fminunc(___)
[x,fval,exitflag,output,grad,hessian] = fminunc(___)

描述

x = fminunc(fun,x0)从x0开始,尝试寻找fun中描述的函数的局部最小值x。 点x0可以是标量,矢量或矩阵

x = fminunc(fun,x0,options)使选项中指定的优化选项最小化。 使用optimoptions来设置这些选项。

x = fminunc(problem) finds the minimum for problem, where problem is a structure described in Input Arguments. Create the problem structure by exporting a problem from Optimization app, as described in Exporting Your Work.

[x,fval] = fminunc(___),对于任何语法,返回的解x

[x,fval,exitflag,output] = fminunc(___)另外返回一个描述fminunc退出条件的值exitflag,以及一个带有关于优化过程信息的结构输出。

[x,fval,exitflag,output,grad,hessian] = fminunc(___)另外返回:
grad — Gradient of fun at the solution x
hessian — Hessian of fun at the solution x. See fminunc Hessian.

例子
Step 1: Write a file objfun.m.

function f = objfun(x)
f = exp(x(1)) * (4*x(1)^2 + 2*x(2)^2 + 4*x(1)*x(2) + 2*x(2) + 1);

Step 2: Set options.
设置选项以使用“quasi-newton”算法。 设置选项是因为“trust-region”算法要求目标函数包含渐变。 如果您没有设置选项,那么根据您的MATLAB®版本,fminunc可以发出警告。

options = optimoptions(@fminunc,'Algorithm','quasi-newton');

Step 3: Invoke fminunc using the options.

x0 = [-1,1]; % Starting guess
[x,fval,exitflag,output] = fminunc(@objfun,x0,options);

结果

Local minimum found.

Optimization completed because the size of the gradient is less than
the default value of the optimality tolerance.

<stopping criteria details>


x =

    0.5000   -1.0000


fval =

   3.6609e-15


exitflag =

     1


output = 

       iterations: 8
        funcCount: 66
         stepsize: 6.3361e-07
     lssteplength: 1
    firstorderopt: 1.2284e-07
        algorithm: 'quasi-newton'
          message: 'Local minimum found.…'

相关文章

  • matlab - fminunc 函数

    功能 找到最小的无约束多变量函数 where f(x) is a function that returns a ...

  • 2018-12-20神经网络参数展开

    为了使用诸如“fminunc()”之类的优化函数,我们将要“展开”所有元素并将它们放入一个长向量中: thetaV...

  • 2018-02-04

    matlab函数之bsxfun

  • JAVA调用matlab程序 输入输出数据转换

    JAVA调用matlab程序 输入输出数据转换 JAVA 程序调用 matlab函数(matlab导出jar包里的...

  • Matlab 打印函数

    Matlab 打印函数: Matlab中plot函数全功能解析 功能二维曲线绘图 语法 plot(Y)plot(X...

  • MATLAB的简单随机生成函数

    关于MATLAB的随机函数: MATLAB含有一些生成随机数的函数: 一、rand ():生成(0,1)区间上均匀...

  • regionprops

    Matlab图像处理函数:regionprops 这里给出在Matlab图像处理工具箱中非常重要的一个图像分析函数...

  • matlab对图像进行处理的函数

    首先还是要对matlab的图像处理函数有一个大致的认识按照matlab对于函数的命名, imread 读取图像 i...

  • MATLAB串口通信与动态绘图

    MATLAB串口通信 MATLAB本身是支持Serial Port Devices,即串口设备。通过自带的一些函数...

  • bar

    matlab中函数bar绘制直方图中的应用函数bar(x)可以绘制直方图

网友评论

    本文标题:matlab - fminunc 函数

    本文链接:https://www.haomeiwen.com/subject/flssjftx.html