フィルターのクリア

Finding multiple locations in a vector

1 回表示 (過去 30 日間)
Bran
Bran 2015 年 10 月 5 日
回答済み: Image Analyst 2015 年 10 月 5 日
I was hoping someone could help, I am trying to use the find function to give me the location of the values of a vector in a larger vector.
ie
[a,b] = find(A==B);
where A is 300 by 1 and B is 20 by 1 but obviously I get an error because B is not a single value. Is there another function that I can use?

回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 10 月 5 日
編集済み: Azzi Abdelmalek 2015 年 10 月 5 日
a=ismember(A,B)
b=find(a)

Image Analyst
Image Analyst 2015 年 10 月 5 日
You can use ismember() as long as they're integers or powers of two. If they're weird floating point numbers, see the FAQ: http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by