为什么这段程序没有运行结果呢?我是小白一枚

clear;
fun='exp(x(1))*(4*x(1)^2+2*x(2)^2+4*x(1)*x(2)+2*x(2)+1)';
x0=[-1,1];
[x,fval]=fminunc(fun,x0)

数组索引不应该是从0开始的吗 x(1)-->x(0) x(2)--->x(1)

这是使用非线性规划求解二元函数的极值,代码没有问题。你运行后输出窗口的输出信息是什么?
以下是我在Matlab2016的的运行结果:

>> options = optimoptions(@fminunc,'Display','iter','Algorithm','quasi-newton');
>> fun='exp(x(1))*(4*x(1)^2+2*x(2)^2+4*x(1)*x(2)+2*x(2)+1)';
>> x0=[-1,1];
>> [x,fval]=fminunc(fun,x0,options)
                                                        First-order 
 Iteration  Func-count       f(x)        Step-size       optimality
     0           3           1.8394                         0.736
     1           9          1.72428       0.368157          0.257  
     2          27        0.0845289        22.5704          0.923  
     3          51         0.072564      0.0012394           1.05  
     4          54       0.00450951              1           0.29  
     5          57      1.15035e-05              1          0.014  
     6          60      2.03682e-07              1        0.00107  
     7          63      3.46174e-12              1       9.29e-06  
     8          66       3.6609e-16              1       7.37e-08  

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-16

图片说明