From: Ulrik Nash on
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.
From: Jos (10584) on
"Ulrik Nash" <uwn(a)sam.sdu.dk> wrote in message <hsbl50$ivi$1(a)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