From: Ashish Uthama on 11 May 2010 09:17 On Tue, 11 May 2010 09:13:04 -0400, Ulrik Nash <uwn(a)sam.sdu.dk> wrote: > 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. >> a=rand(3,2) a = 0.2277 0.9234 0.4357 0.4302 0.3111 0.1848 >> b=[.1 .4] b = 0.1000 0.4000 >> bsxfun(@(ai,bj)ai>bj,a,b) ans = 1 1 1 1 1 0
|
Pages: 1 Prev: Help needed in OFDM Next: Simulations of Silicon Waveguide |