Finding the index (rank) of a specific number from a column

2 ビュー (過去 30 日間)
Abbi Hashem
Abbi Hashem 2018 年 12 月 10 日
コメント済み: Abbi Hashem 2018 年 12 月 10 日
Suppose I have a column B = [ 1 4 8 3 5 9]
and I have another vector = [ 8]
In this case, I want to find the rank where it's matched in the vector which should return a value of 3 (3rd). How do I do that ?
  3 件のコメント
Abbi Hashem
Abbi Hashem 2018 年 12 月 10 日
if you look at the vector , the 1st value is 4 , second is 4 , third is 8 ... the "3 " as in third value is what I want to obain
madhan ravi
madhan ravi 2018 年 12 月 10 日
I got confused because you said rank so you mean index

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

採用された回答

Walter Roberson
Walter Roberson 2018 年 12 月 10 日
[~, idx] = ismember(8, B)
  3 件のコメント
Walter Roberson
Walter Roberson 2018 年 12 月 10 日
just_a_variable = 8;
[~, rank_that_you_are_looking_for_this_is_the_result_that_you_want] = ismember(just_a_variable, B);
Abbi Hashem
Abbi Hashem 2018 年 12 月 10 日
thanks

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by