I have a question to the mapping of a matrix with another matrix which contains only 1 and 0. Here an example of my problem: A is the matrix with doubles
A
Just multiply A and B element-wise:
C = A.*B
I like Dan's solution, but this would be another way:
C = zeros(size(A)); C(B==1) = A(B==1);