Matching two matrices by sign

조회 수: 1 (최근 30일)
joseph Frank
joseph Frank 2013년 8월 4일
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;

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 8월 4일
편집: Azzi Abdelmalek 2013년 8월 4일
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
Cedric
Cedric 2013년 8월 4일
or
isOk = all( sign(A(:)) == sign(B(:)) ) ;

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Antenna and Array Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by