Assume I have one matrix with two columns. Every column has thousands of values. The elements of the 1st column are normal numbers. The elements of the 2nd column are 0 or 1. For simplicity, take this example:
U = [ 25 36 12 52 32 12 14 ; 0 1 1 0 0 0 1]'
I want to create a new one column matrix P such that if the element of the 2nd column of U is 0, then the element of P is the same as the corresponding one in the 1st column. But, if the element of the 2nd column of U is 1, then the element of P is zero.
So, the result of the above example is:
P = [25 0 0 52 32 12 0]'