Maximum of a function with elements from a vector

1 vue (au cours des 30 derniers jours)
Ben M
Ben M le 15 Nov 2020
Modifié(e) : Ameer Hamza le 16 Nov 2020
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 commentaires
Ameer Hamza
Ameer Hamza le 15 Nov 2020
Is the objective function correct? In the current form, it seems that the maximum value is infinity.
Ben M
Ben M le 15 Nov 2020
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!

Connectez-vous pour commenter.

Réponses (1)

Ameer Hamza
Ameer Hamza le 16 Nov 2020
Modifié(e) : Ameer Hamza le 16 Nov 2020
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.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by