How to select the x-value of the maximum of a figure (without using ginput)?
조회 수: 1 (최근 30일)
이전 댓글 표시
I've got a figure (see attachment). I want to select the x-value of it's maximum. How do I do this?
댓글 수: 0
채택된 답변
Star Strider
2014년 12월 23일
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);
댓글 수: 0
추가 답변 (1개)
Sean de Wolski
2014년 12월 23일
편집: Sean de Wolski
2014년 12월 23일
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)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!