```Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Creating matrix of 1's and 0's based on a comparison of values in two other matrixes
Date: Tue, 11 May 2010 13:19:04 +0000 (UTC)
Organization: Erasmus MC
Lines: 41
Message-ID: <hsblg8\$bl2\$1@fred.mathworks.com>
References: <hsbl50\$ivi\$1@fred.mathworks.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1273583944 11938 172.30.248.38 (11 May 2010 13:19:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 11 May 2010 13:19:04 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:634572

"Ulrik Nash" <uwn@sam.sdu.dk> wrote in message <hsbl50\$ivi\$1@fred.mathworks.com>...
> Hi Everyone,
>
> I have two matrixes:
>
> A =
>
>      1     2
>      3     4
>      5     1
>
> and
>
> B =
>
>      1     3
>
> Now I wish to create matrix C, which has the same dimensions as A. C should look like this:
>
> C =
>
> 0  0
> 1  1
> 1  0
>
> C is generated by 'asking' for every number in a column of A, if that number is smaller than or equal to the number in the corresponding column of B. If this is the case, then a 0 is entered in C or else 1 is entered.
>
> I am sure there is a simple way of doing this in Matlab, but I haven't found it.
>
> I appreciate the help.
>
> /Ulrik.

help bsxfun

A = [1 2 ; 3 4 ; 51 1]
B = [1 3]
C = bsxfun(@lt, B, A)

hth
Jos
```