finding all the maximum/minimum and their corresponding x values

18 ビュー (過去 30 日間)
Eliraz Nahum
Eliraz Nahum 2018 年 9 月 24 日
回答済み: Image Analyst 2018 年 9 月 24 日
hello I want to know how I can find all the max values (even if there are many same maximums, like [1 2 3 6 6 6]) of a vector and not only the maximum value found in the vector. I also want to find the corresponding x_values in another vector that relate to the maximum/minimum values found earlier in y_values. I know that there is an option to use: xmin=x(y==Ymin), but which point in the 2D space I will get out of the numerous existing.

採用された回答

Image Analyst
Image Analyst 2018 年 9 月 24 日
Try this
maxY = max(y);
% Find all locations
indexesOfMax = find(y == maxY)
% Find x values at corresponding locations:
xAtMaxima = x(indexesOfMax)
Not sure what you're talking about with 2-D space. This makes no sense to me: "which point in the 2D space I will get out of the numerous existing" A vector is a 1-D situation, not a 2-D situation, even if it's a curve of y vs. x.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by