If same value in two matrices, keep the value in the first matrix <p>how can I achieve the matrix C with following conditions: A(i,j) is any B(k) , then A(i,j) = B(k) else A(i,j) = 0</p> <p>example:</p> <p>A = [1 0 3 6 3 4; 2 0 3 1 8 2]; B = [1;2;3];</p> <p>C = [1 0 3 0 3 0; 2 0 3 1 0 2]</p> <p>Thank you!</p>