Finding the maximum of the constrained function
이전 댓글 표시
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개)
카테고리
도움말 센터 및 File Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!