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!