Problem 2592. LocateMembership | Membership of Matrix in another matrix
Solution Stats
Problem Comments
-
5 Comments
in test case 3, b is not available in a. I might be wrong.. Please Check
Not logic to ask a scalar (if no location), an array (if 1), and a cell (if 2). And why not add the example (difficult) in the tests ?
@rifat : updated, thanks for info
Nice problem. Some solutions (using conv, filter2 etc.) doesn't check conditions properly. Adding a=2*ones(4); b=3*eye(3)+1; or a=0; b=0; or similar can improve the testsuite;
The solution in the example is [2 2;3 3].
Solution Comments
-
3 Comments
@Jean-Marie, using ismember(a,b) and comparing it with a 2D window of ones works in this particular case. But, ismember does not consider the order of the elements. You can verify this by calling LocateMembership(a,b') for the second test case. You would see that it results [2 4] though it is not correct.
@rifat, you're right. At the beginning, before the first corrections, I thought it was the goal of this problem (b can be created using a in any order) and I kept this approach.By the way @Vishal, it's a very interesting problem !
@Jean - Thanks.
Problem Recent Solvers21
Suggested Problems
-
Make the vector [1 2 3 4 5 6 7 8 9 10]
43955 Solvers
-
Swap the first and last columns
17142 Solvers
-
2172 Solvers
-
4047 Solvers
-
386 Solvers
More from this Author6
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!