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.
Reverse Run-Length Encoder
Find the sum of the elements in the "second" diagonal
Back to basics 11 - Max Integer
Whether the input is vector?
07 - Common functions and indexing 5
Look Up Mapping
Replace Nonzero Numbers with 1
Angle difference between Hour Hand and Minute Hand of clock
Repeat The Components of Matrix
What is Sum Of all elements of Matrix
Find the treasures in MATLAB Central and discover how the community can help you!
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office