我必须最小化transpose(x)*A*x ./ transpose(x)*B*x
函数,其中x是向量,A和B是矩阵。 matlab中是否有一个函数可以最小化它?
由于
答案 0 :(得分:0)
如果你有一个多变量标量函数(看起来你有),你可以使用fminunc
,提到here。
另外,我认为你试图执行(x' A x)/(x' B x)< - 撇号在MATLAB中转置。
以下是一个例子:
>> A = rand(3)
A =
0.8491 0.7577 0.6555
0.9340 0.7431 0.1712
0.6787 0.3922 0.7060
>> B = rand(3)
B =
0.0318 0.0971 0.3171
0.2769 0.8235 0.9502
0.0462 0.6948 0.0344
>> f = @(x)x'*A*x./(x'*B*x);
>> fminunc(f,[1;2;4]) % some arbitrary starting guess.
Warning: Gradient must be provided for trust-region algorithm; using quasi-newton algorithm instead.
> In fminunc at 403
Local minimum found.
Optimization completed because the size of the gradient is less than the default value of the function tolerance.
<stopping criteria details>
ans =
-7.3912
2.1750
5.5588
>>