Matching two matrices by sign

2 views (last 30 days)
B=[2,4,-2; 2,-1,-3];
How can I get that the sign of B(2,3) is different than the sign of A(2,3)? i.e. the signs of A and B should be the same. I want to find if I have any observation in B that doesn't match the sign of the respective value in A;

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 4 Aug 2013
Edited: Azzi Abdelmalek on 4 Aug 2013
For the whole matrices
B=[2,4,-2; 2,-1,-3];
  1 Comment
Cedric Wannaz
Cedric Wannaz on 4 Aug 2013
isOk = all( sign(A(:)) == sign(B(:)) ) ;

Sign in to comment.

More Answers (0)


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by