Reputation: 77
I have 2 matrices, say
A = [ 0 4 9 B = [ 0 0 2
0 2 1 1 6 1
3 0 0 ] 3 9 8 ]
I want the result to be "A overlapped with B".
B
which are 0
should be "transparent" and show through the value of A
B
.So I should get:
result = [ 0 4 2
1 6 1
3 9 8 ]
Upvotes: 1
Views: 52
Reputation: 602
A=[ 0 4 9;
0 2 1;
3 0 0];
B=[ 0 0 2;
1 6 1;
3 9 8];
result = A;
result( B~=0 ) = B( B~=0 );
Upvotes: 3