필터 지우기
필터 지우기

row wise output for find(ismember(Values, searchValues,'rows'))

조회 수: 1 (최근 30일)
Sad Grad Student
Sad Grad Student 2015년 2월 17일
댓글: Sad Grad Student 2015년 2월 17일
I have two matrices say foo and bah as follows:
>> foo =
2 19
5 68
17 19
65 37
73 62
65 78
45 9
55 93
30 77
74 49
>> bah
bah =
5 68
65 78
65 78
55 93
55 93
55 93
55 93
To get the indices, I am doing:
>> find(ismember(foo,bah,'rows'))
ans =
2
6
8
I want the answer as:
2
6
6
8
8
8
8
corresponding to each row of the bah matrix. How do I get such an output?? I tried using bsxfun/arrayfun/isequal/intersect?! Unique will just make it more difficult to map it back!
Please help! I really want to avoid a for loop here to go through each row and want a smarter way to do it!
Thanks! :)
Alpa.

채택된 답변

Image Analyst
Image Analyst 2015년 2월 17일
Alpa:
Try using all return arguments of ismember():
[~, rows] = ismember(bah, foo,'rows')
  댓글 수: 1
Sad Grad Student
Sad Grad Student 2015년 2월 17일
Yes! That's exactly what I was looking for! I knew it had to be something this silly! Thank you very much :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Sparse Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by