Matching two matrices by sign

1 visualización (últimos 30 días)
joseph Frank
joseph Frank el 4 de Ag. de 2013
A=[1,1,-3;2,-1,4];
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;

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 4 de Ag. de 2013
Editada: Azzi Abdelmalek el 4 de Ag. de 2013
sign(B(2,3))==sign(A(2,3))
For the whole matrices
A=[1,1,-3;2,-1,4];
B=[2,4,-2; 2,-1,-3];
[ii,jj]=find(sign(A)==sign(B))
  1 comentario
Cedric
Cedric el 4 de Ag. de 2013
or
isOk = all( sign(A(:)) == sign(B(:)) ) ;

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB Compiler en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by