views:

74

answers:

1

Hey,

I want to know how to perform an and operation on 2 numbers in MATLAB

ex :-

x = 31   '11111' ;

y = 23   '10111' ;

If I use the AND operation on this 2 numbers I will get

z = x AND y

z will be 23 due to AND operation

How can I do this in MATLAB ?

+8  A: 

You can just use the bitand function, e.g.

octave-3.2.3:1> x = 31
x =  31
octave-3.2.3:2> y = 23
y =  23
octave-3.2.3:3> z = bitand(x, y)
z =  23
Paul R

related questions