Finding the maximum of the constrained function
1 view (last 30 days)
Show older comments
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?
0 Comments
Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!