Minimum point of Graph

51 次查看(过去 30 天)
I have plotted a parabola like curve in the rough shape of (y=x^2). How am I able to draw plot a verical line from the minimum of the graph where the gradient is zero to the x axis and have this labbled as (Xminimum). Is it also possible to obtain an x value at which this value occurs on the graph too
Thanks

采纳的回答

Mark Sherstan
Mark Sherstan 2018-12-13
编辑:Mark Sherstan 2018-12-13
Use the islocalmin function:
x = -5:0.1:5;
y = x.^2;
idx = islocalmin(y);
figure(1)
hold on
plot(x,y)
plot(x(idx),y(idx),'*r')
legend('Curve','Local Min')
hold off
fprintf('Min located at %0.2f\n',x(idx))
  5 个评论
Mark Sherstan
Mark Sherstan 2018-12-13
Right now this is a black dashed line. More options can be found towards the bottom of the page here.
line([x(idx) x(idx)],[y(idx) 0],'color','k','LineStyle','--')
Andrew Kay
Andrew Kay 2018-12-13
Very Helpful, thanks for your time

请先登录,再进行评论。

更多回答(1 个)

madhan ravi
madhan ravi 2018-12-13
syms x
y=x^2
x=solve(diff(y)==0)

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by