Q:

convert specific number to zero in matlab

i don't know if it's possible but i may give it a try: if i have an array
 A=[ 10 10  5
    2   6   1
    3   7   2
    6   10  5
    4   8   6
    7   1   7
    8   12  8]

which is 7x3 dimension
and another array 
B=  [4 6 7]

which is 1x3 dimension, so as you can see the number of columns are the same.
so this is what i want to do,
in column 1 array A, i want to convert values less than the number in column 1 array B or 4 to zero, while in column 2 array A, i want to convert those values less than the number in column 2 array B in zero, also i wan to do that in column 3 array A.
then the output become:
 AB=[ 10    10  5
    0   6   0
    0   7   0
    6   10  0
    4   8   0
    7   0   7
    8   12  8]

the idea is if you have an mxn array and another 1xn array it will automatically convert those values to zero which is dependent on what are the values in your 1xn array.
so is it possible? thanks.

A:

bsxfun(@gt,A,B).*A should do it.
My result is:
10    10     0
 0     0     0
 0     7     0
 6    10     0
 0     8     0
 7     0     0
 8    12     8

Explanation:
The MATLAB function bsxfun lets you perform element-wise operations on arrays with singleton expansion (because of this it is one of the language's most useful functions).
The first argument is the operation you wish to perform. @gt is the the "greater than" operator >. You can also use @plus for addition +, @times for multiplication *, and so forth (check the documentation for a complete list).
If the arrays A and B are equal in size, the operation is done element-by-element. If they are different (as in the above case), whenever one array has a singleton dimension (a dimension of size 1), bsxfun replicates the array along that dimension.
So the array B = [4 6 7] is converted into
[ 4 6 7
  4 6 7
  4 6 7
  4 6 7
  4 6 7
  4 6 7
  4 6 7 ]

To match the dimensions of A. Then bsxfun just applies the > operation element-by-element.

