Maxima of a function using fminbnd

5 ビュー (過去 30 日間)
Snirisa  Gödel
Snirisa Gödel 2014 年 3 月 31 日
コメント済み: Alan Weiss 2014 年 4 月 1 日
I want to find the maximum of lambda for a function M(lambda,T), describing the radiation, for fixed values of T using the method fminbnd. Basically it is a well-known formula for radiation and I want to know if there is some obvious things that are wrong. So, I red through the help section and came up with this:
%
T1=3000; %Define parameter
T2=4000;
T3=5000;
fminbnd(@(lambda)planck(lambda,T1),0,1e-5)%Second bound is chosen arbitrary
fminbnd(@(lambda)planck(lambda,T1),0,1e-5)
fminbnd(@(lambda)planck(lambda,T1),0,1e-5)
All gives the same output..which is clearly wrong.
The function is defined by
%
function M=planck(lambda,T)
h=6.6256e-34;
c=2.9979e8;
k=1.3805e-23;
a=2*pi*h*c^2;
b=h*c/k./lambda./T;
M=-a./lambda.^5./(exp(b)-1); %I put a minus sign since I want to minimize the negative function

採用された回答

Alan Weiss
Alan Weiss 2014 年 3 月 31 日
The problem is you are running into some scaling issues. Try scaling your problem so that the value of lambda is between 0 and 1.
scaledplanck = @(x,lambda)planck(x*1e-5,lambda);
fminbnd(@(lambda)scaledplanck(lambda,T1),0,1)
fminbnd(@(lambda)scaledplanck(lambda,T2),0,1)
fminbnd(@(lambda)scaledplanck(lambda,T3),0,1)
Alan Weiss
MATLAB mathematical toolbox documentation
  2 件のコメント
Snirisa  Gödel
Snirisa Gödel 2014 年 3 月 31 日
Thank you. How did you see that? And when do they occur? (In case I'll run into it again in the future)
Alan Weiss
Alan Weiss 2014 年 4 月 1 日
I suspected it from the start, but I saw it by plotting the functions for various values of T, and saw that fminbnd was not giving a correct answer.
There are various stopping criteria for optimization solvers, and one is called TolX, which stops the solver when steps are too small. This tolerance applies to fminbnd, and I believe that is why fminbnd stopped too soon.
Alan Weiss
MATLAB mathematical toolbox documentation

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by