How to select the x-value of the maximum of a figure (without using ginput)?

 Réponse acceptée

I would use the max function with two output arguments, then use the index value to find the x-value:
[ymax,idx] = max(y);
xmax = x(idx);

Plus de réponses (1)

Sean de Wolski
Sean de Wolski le 23 Déc 2014
Modifié(e) : Sean de Wolski le 23 Déc 2014
You could use datacursortmode the axes 'ButtonDownFcn' or max() on the line's 'YData'. This is what I would do.
plot(rand(1,10));
hLine = findobj(gca,'type','line');
[~,idx] = max(hLine.YData)
hLine.XData(idx)

Catégories

En savoir plus sur Graphics Object Properties dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by