Maximum of a function with elements from a vector
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello guys,
I want to find the maximum of the following function:
f(µ) = (1/n)*
log(
-µ)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/414693/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/414698/image.png)
where n=24 and
is a vector with 24 elements.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/414703/image.png)
Can someone help me?
Many thanks in advance !!!
2 commentaires
Ameer Hamza
le 15 Nov 2020
Is the objective function correct? In the current form, it seems that the maximum value is infinity.
Réponses (1)
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.
0 commentaires
Voir également
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!