find something strange when using rot90. the matrix are not equal nor equal. In this case 33 appears in the answer.
조회 수: 8 (최근 30일)
이전 댓글 표시
A=randi(2,3,3);
B=rot90(A);
if A==B
11
elseif A~=B
22
else
33
end
댓글 수: 0
채택된 답변
Walter Roberson
2014년 3월 11일
An evaluated expression is true when the result is nonempty and contains all nonzero elements (logical or real numeric). Otherwise, the expression is false.
The A==B is not true because there is at least one element that does not match. The A=~B is not true because there is at least one element that does match. So you get the third possibility.
추가 답변 (1개)
Dishant Arora
2014년 3월 11일
A and B are matrices not scalar compare them using isequal. Try this
if isequal(A,B)
% do something
elseif ~isequal(A,B)
% do something
And to know what you did wrong in your code type this:
A==B
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!