I want to a element-by-element binary operation apply to large logical vectors. The content of these vectors is manly false, so for performance considerations it better to work with sparse matrices. If i do so the resulting matrix is not correct.
Examble
A = logical([0;1;0;0]);
B = logical([0 0 1 1]);
C = bsxfun(@and,A,B)
In this case C is
C =
0 0 0 0
0 0 1 1
0 0 0 0
0 0 0 0
If i use sparse matrices C is
C = full(bsxfun(@and,sparse(A),sparse(B)))
C =
0 0 0 0
1 1 1 1
0 0 0 0
0 0 0 0
Which is obviously wrong.
Did i oversee something or is this a Matlab bug.