Maximum of a function with elements from a vector

1 回表示 (過去 30 日間)
Ben M
Ben M 2020 年 11 月 15 日
編集済み: Ameer Hamza 2020 年 11 月 16 日
Hello guys,
I want to find the maximum of the following function:
f(µ) = (1/n)*log(-µ)
where n=24 and is a vector with 24 elements.
Can someone help me?
Many thanks in advance !!!
  2 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 11 月 15 日
Is the objective function correct? In the current form, it seems that the maximum value is infinity.
Ben M
Ben M 2020 年 11 月 15 日
It´s just an example. The real function for my problem is more difficult. Basically i want to know how i can calculate a maximum of a function f(µ), which contains a "sum", a variabel (here µ) and a vector elemement (here ). I think the first Step is to define the above mentioned function. Thanks!

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

回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 11 月 16 日
編集済み: Ameer Hamza 2020 年 11 月 16 日
You can define this objective function like this
u = 0; % for example
n = 24;
f = @(x) -1/n*sum(log(x-u));
x0 = rand(n,1);
fmincon(f, x0)
I used minus (-) with the objective function because MATLAB optimization functions are defined for minimization problem. This convert your problem from maximization to minimization.

カテゴリ

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