x value on y max

49 ビュー (過去 30 日間)
Simon
Simon 2013 年 4 月 17 日
コメント済み: Image Analyst 2022 年 10 月 14 日
Hi! How do I get matlab to show me the x value on my max y value that I have in my function and in my graph. I have already tried to find it by using plot(x,y) but don't know how.
Would be really nice to get an answer on my simple question.
Sincerely Simon

採用された回答

Image Analyst
Image Analyst 2013 年 4 月 17 日
編集済み: Image Analyst 2013 年 4 月 17 日
xIndex = find(y == max(y), 1, 'first');
maxXValue = x(xIndex);
Or
[maxYValue, indexAtMaxY] = max(y);
xValueAtMaxYValue = x(indexAtMaxY(1));
The (1) is there in case the max occurs at multiple places, it takes the first.
  14 件のコメント
khaled elbatawy
khaled elbatawy 2022 年 10 月 14 日
Hello,
@Image Analyst i know that it is old answer but it is related somehow to my Problem.
The different is my Data (y) is oscilating.
I want for every Maxima/Minima of y to find the corresponding Value of x. But without using findpeaks(Data)because it is needed the Signal Processing Toolbox.
Thank you in advance !
Image Analyst
Image Analyst 2022 年 10 月 14 日

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by