fminsearch used in a complex way

7 ビュー (過去 30 日間)
Elroy
Elroy 2015 年 11 月 11 日
コメント済み: Walter Roberson 2015 年 11 月 11 日
Hi All,
Trying to sort out a specific application of fminsearch. Here it is:
options = optimset('Display', 'off', 'Diagnostics', 'on', 'GradObj', 'off', 'TolX', 1e-6, 'TolFun',1e-6, 'MaxFunEvals', 1000);
p = fminsearch(@(c) calc_global_angle(c, Rx*Ry, p_global), p_global, options);
And here's the calc_global_angle function:
function [residual, value] = calc_global_angle(ang, mat, p)
Rz = build_Rz(ang);
T = mat*Rz;
value = -asin(T(1,2)/sqrt(T(1,2)^2+T(2,2)^2));
residual = abs(value - p);
I can also tell you this: Rx is a 3x3 matrix. Ry is a 3x3 matrix. p_global is a scalar. p is a scalar.
And c just appears. I'm not exactly sure where the variable c comes from. It just appears, just as you see it in the p = fminsearch(...) line.
I'm also quite unclear on how you can find the minimum of a function that returns two variables (or a two element vector, if you prefer). Is it minimizing on value or residual?
Also, since the calc_global_angle takes three arguments (c, a 3x3 matrix, and another scalar), why is fminsearch returning only a scalar? Shouldn't it return the three arguments that minimize the function?
Any explanations and help that people feel like providing would be much appreciated.
Regards, Elroy

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 11 月 11 日
  3 件のコメント
Elroy
Elroy 2015 年 11 月 11 日
That's not right either. Minimizing a plane would take two inputs, and NOT two outputs. I just don't see what it means to minimize a function with two outputs.
Walter Roberson
Walter Roberson 2015 年 11 月 11 日
fun is the function to be minimized. It accepts an input x and returns a scalar f, the objective function evaluated at x.
The second output is simply being ignored.
The first output happens to be your "residue", so basically you are searching for the angle that returns the smallest residue.
fminsearch uses a simplex type search that does not necessarily get stuck in any given local minimum, but certainly can get stuck in local minima. fminsearch() is not a global minimizer.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by