Using find() to identify values in an array that are present in another array

I am trying to extract values in rows 2 and 3 from an array when the corresponding value in row 1 is equal to a certain value present in a list (another array). I am attempting to do this with find(), and am wondering if there is a way to incorporate ismember(), but I am no sure how to proceed. I have attached screenshot of my main array below. The values change from left to right over 7136 columns, but the increments are very fine. Thanks!

 採用された回答

Dr.Vini42
Dr.Vini42 2017 年 2 月 21 日

0 投票

Okay, I got it to work now. The first answer was close, but this one is correct. For some reason using ismember() changed the syntax of find(). I assume it has to do with the output of ismember(), but perhaps someone else could offer a more thorough explanation.
find(ismember(comparison_array),array(1,:));

その他の回答 (1 件)

Dr.Vini42
Dr.Vini42 2017 年 2 月 21 日
編集済み: Dr.Vini42 2017 年 2 月 21 日

0 投票

Never mind, I discovered a solution.
find(array(ismember(comparison_array),array(1,:)));

4 件のコメント

Dr.Vini42
Dr.Vini42 2017 年 2 月 21 日
Should I delete my question since I was able to answer it for myself, or should I leave it up so that others with similar questions can find it?
Image Analyst
Image Analyst 2017 年 2 月 21 日
You can leave it. I mean there are already over a hundred thousand other questions in there, so what's one more? Plus it might be useful to someone.
Dr.Vini42
Dr.Vini42 2017 年 2 月 21 日
Thanks!
Dr.Vini42
Dr.Vini42 2017 年 2 月 21 日
編集済み: Dr.Vini42 2017 年 2 月 21 日
Actually, I changed my mind. My solution is not working quite as I intended. Perhaps there is a better way. My solution appears to be withdrawing the first X values from my array, according to how many values are in my comparison_array. This was not initially obvious because of the small incrementation I had mentioned.

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

カテゴリ

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

質問済み:

2017 年 2 月 21 日

回答済み:

2017 年 2 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by