find something strange when using rot90. the matrix are not equal nor equal. In this case 33 appears in the answer.
6 ビュー (過去 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!