为什么在八度中比较矩阵不被评估为布尔值? [英] Why comparing matrices is not evaluated as boolean in Octave?
本文介绍了为什么在八度中比较矩阵不被评估为布尔值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是Octave的新手,可以在控制台上玩耍.
Im new to Octave and playing around with the console.
为什么在比较矩阵时,表达式的计算结果不是布尔值:
why when comparing matrices, the expression is not evaluates as boolean :
示例:
>> A=[1,2;3,4]; % creating 2x2 matrix
>> 5 == 5 % sample comparison returns true (1)
ans = 1
>> A(1,1) == A(1,1) % single element comparison returns true (1)
ans = 1
>> A == A % returns 2x2 matrix ???
ans =
1 1
1 1
>> size(A == A) % prove that the above returns 2x2 matrix
ans =
2 2
推荐答案
==
用于两个矩阵的逐元素比较.要检查两个矩阵是否相同,请使用 isequal
这篇关于为什么在八度中比较矩阵不被评估为布尔值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文