フィルターのクリア

how to get all max values of one vector

5 ビュー (過去 30 日間)
Francesco Grechi
Francesco Grechi 2021 年 4 月 2 日
コメント済み: Francesco Grechi 2021 年 4 月 2 日
i have for example the following vactor: X = [ 1 2 3 4 5 7 7 3 5 3 2 7]
my aim is to get all the maximum values, so in the vector X the maximum value is 7 and i can find it as Value_max = max(X);
however this function consider only the first 7 and i need a function that give to me all the 7 so the result that i need is Y = [7 7 7]

採用された回答

David Hill
David Hill 2021 年 4 月 2 日
m=X(ismember(X,max(X)));
  1 件のコメント
Francesco Grechi
Francesco Grechi 2021 年 4 月 2 日
it works thank you

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2021 年 4 月 2 日
Try this
indexes = find(X == max(X));
result = X(indexes)
  1 件のコメント
Francesco Grechi
Francesco Grechi 2021 年 4 月 2 日
it works thank you

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

カテゴリ

Help Center および File ExchangeState-Space Control Design and Estimation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by