Path: news.mathworks.com!newsfeed-00.mathworks.com!news.tele.dk!feed118.news.tele.dk!feed116.news.tele.dk!bofh.vszbr.cz!news.radio.cz!newsreader4.netcologne.de!news.netcologne.de!feeds.phibee-telecom.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!gegeweb.org!aioe.org!.POSTED!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Finding a small matrix in larger one
Date: Wed, 08 Feb 2012 15:24:22 -0600
Organization: Aioe.org NNTP Server
Lines: 28
Message-ID: <jgup63$pob$1@speranza.aioe.org>
References: <jgu4lt$8f4$1@newsfeed1.man.lodz.pl> <jgukme$e8k$1@speranza.aioe.org> <jgunu4$t6j$1@newsfeed1.man.lodz.pl>
NNTP-Posting-Host: yYONfaJqtKgW9SB89zd/GA.user.speranza.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11
X-Notice: Filtered by postfilter v. 0.8.2
Xref: news.mathworks.com comp.soft-sys.matlab:757165

On 2/8/2012 3:02 PM, camilla belle wrote:
> For unique numbers it will work but for repeated it will show every number
> from B that equals one from A.
...

That's true...

You didn't specify the application.

But, the above was shown to demonstrate one starting point containing 
the necessary information--add the logic to the above to test that there 
is an area of the size of the smaller within the area that is all TRUE, 
essentially by deleting contiguous rows in which all elements are 0 and 
see if can end up w/ a sub-array the size of the target which satisfies 
all(subarray)==TRUE

The more a priori knowledge you have regarding the location of such a 
subarray within the larger, the more you can streamline the process--if, 
for example, you knew there can't be row in the middle of the subarray 
if it exists that is not part of that array, then you can use any() and 
all() w/ the dimension arguments and set the found rows/columns = [] w/o 
additional checking, just using the found indices.  If, otoh, you could 
have a row (say) that is all false in the middle of a pattern and that 
eliminating that row would create a false subarray, then you would need 
to only eliminate rows/columns that are not inside a potential area, 
much like Roger's solution.

--