Finding the maximum of the constrained function
Afficher commentaires plus anciens
I have the function $f(a)=-(a - \beta)^2 + 8$ with constraints $a \leq$ 0$ and $a \geq 8$. I want to use *if* statements to calculate the constrained maximum and want to plot the solution in a graph, i.e, the solution should be a point on the graph of the function.
So far I have the graph of the function with the following code:
beta = -0.5;
a = linspace(-3,7);
f = @(a) 8 - (a - beta).^2;
amin = 0
amax = 8
figure
plot(a,f(a))
axis([-3 10 0 10])
hold on
plot(amin,f(a))
plot(amax,f(a))I also want to draw vertical lines of the constrains at $a=0$ and $a=8$ going all the way to $f(a)=10$. How do I do that?
Réponses (0)
Catégories
En savoir plus sur Graph and Network Algorithms dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!