i have a vector matrix for example [20,3,56,7,8,96,52,22] and i have another value x=8. now i wanna find the index number of x in that vector without using for or while loop thank you for your help

1 件のコメント

David Goodmanson
David Goodmanson 2016 年 11 月 30 日
Hi Hamid, take a look at the 'find' function

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

回答 (1 件)

Guillaume
Guillaume 2016 年 11 月 30 日

1 投票

[~, index] = ismember(8, [20, 3, 56, 7, 8, 96, 52, 22]);
or
index = find([20, 3, 56, 7, 8, 96, 52, 22] == 8);

1 件のコメント

Hamid Bakht
Hamid Bakht 2016 年 11 月 30 日
thank you so much really helped

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

カテゴリ

ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索

タグ

質問済み:

2016 年 11 月 30 日

コメント済み:

2016 年 11 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by