How can I show the max point on a plot ?

218 visualizaciones (últimos 30 días)
Ahmed Alhawaj
Ahmed Alhawaj el 18 de Abr. de 2020
Comentada: darova el 18 de Abr. de 2020
I am having hard time figuring out a way to show the max point on a plot
  1 comentario
darova
darova el 18 de Abr. de 2020
Can you show the code? Did you try max function?

Iniciar sesión para comentar.

Respuestas (1)

Star Strider
Star Strider el 18 de Abr. de 2020
Depending on what you want to do, and if there is only one maximum:
x = 0:10;
y = -(x-5).^2;
[ymax,idx] = max(y); % Maximum Of Dependent Variable & Index
figure
plot(x, y)
hold on
plot(x(idx), ymax, '^r')
hold off
grid
ylim([min(ylim) max(ylim)+1])
.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by