find local maximum/minima
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Muhammad Zahirul Mohd Rodzuan
el 2 de Nov. de 2020
Editada: Ameer Hamza
el 2 de Nov. de 2020
how do i find the local maxima and minima for f(x,y)=110*x-4.5*x^2+115*y-2*y^2. this is my first time using matlab and i am not familiar with the function of the solver.
0 comentarios
Respuestas (1)
Ameer Hamza
el 2 de Nov. de 2020
Editada: Ameer Hamza
el 2 de Nov. de 2020
Your function is Paraboloid, and it only has single minima or maxima.
If you have a symbolic toolbox, you can find the gradient and zero it to find the stationary point.
syms x y
f = 110*x-4.5*x^2+115*y-2*y^2;
df = gradient(f);
sol = solve(df)
Result
>> sol.x
ans =
110/9
>> sol.y
ans =
115/4
To check if it is minima or maxima, we can use hessian matrix
d2f = hessian(f)
Result
>> d2f = hessian(f)
d2f =
[-9, 0]
[ 0, -4]
The hessian is negative definite, therefore, the stationary point is maxima.
If you have optimization toolbox, then you can also try fmincon()
f = @(x,y) 110*x-4.5*x.^2+115*y-2*y.^2;
sol = fmincon(@(X) -f(X(1), X(2)), rand(2,1))
0 comentarios
Ver también
Categorías
Más información sobre Global or Multiple Starting Point Search en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!