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].
@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.
1262 Solvers
1366 Solvers
Find the elements of a matrix according to a defined property.
72 Solvers
5088 Solvers
365 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!