Multivariable Optimization problem with MATLAB

2 ビュー (過去 30 日間)
Arindam Sutradhar
Arindam Sutradhar 2019 年 1 月 20 日
回答済み: Alan Weiss 2019 年 1 月 22 日
I wish to find a maximum for the following function, the function is m:
x = normrnd(0,1,[1,5]);
global x
xbar=mean(x);
global xbar
n=length(x);
global n
an = @(a0,b0,k0,m0) a0+n/2;
bn = @(a0,b0,k0,m0) (b0 + ((n-1) * sum((x-xbar).^2))/2 + ((k0 * n * ((xbar-m0).^2) )/(2*(k0 + n))));
kn = @(a0,b0,k0,m0) (k0 + n);
mn = @(a0,b0,k0,m0) ((k0 * m0)+(n.*xbar))/(k0 + n);
m=@(a0,b0,k0,m0)(gamma(an(a0,b0,k0,m0))/gamma(a0)) * ((b0^a0)/(bn(a0,b0,k0,m0).^an(a0,b0,k0,m0))) * (sqrt(k0/kn(a0,b0,k0,m0))) * ((2*pi)^(-n/2))
This is not linear. I wish to find a Global maximum. Most of the function I found in matlab handles the polynomials. But I do not find any particular function that gives me a maximum for this. I tried to use 'fminunc'. But that is showing me an error message
"Failure in initial objective function evaluation. FMINUNC cannot continue."
Looking forward to some help. Thanks in advance.

回答 (1 件)

Alan Weiss
Alan Weiss 2019 年 1 月 22 日
I don't understand what you are trying to do exactly. But for troubleshooting, you need to ensure that the function handle that you pass to fminunc calculates a scalar numerical value at the initial point x0. So try to evaluate
fun(x0)
where fun is your objective function and x0 is your initial point. Undoubtedly, this will evaluate to a nonscalar value, or will fail to evaluate. That is where you need to start your investigation.
Alan Weiss
MATLAB mathematical toolbox documentation

カテゴリ

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