Minimum point of Graph

52 visualizaciones (últimos 30 días)
Andrew Kay
Andrew Kay el 13 de Dic. de 2018
Comentada: Andrew Kay el 13 de Dic. de 2018
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

Respuesta aceptada

Mark Sherstan
Mark Sherstan el 13 de Dic. de 2018
Editada: Mark Sherstan el 13 de Dic. de 2018
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 comentarios
Mark Sherstan
Mark Sherstan el 13 de Dic. de 2018
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 el 13 de Dic. de 2018
Very Helpful, thanks for your time

Iniciar sesión para comentar.

Más respuestas (1)

madhan ravi
madhan ravi el 13 de Dic. de 2018
syms x
y=x^2
x=solve(diff(y)==0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by