Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
|
![]() |
#1 |
普通会员
注册日期: 2008-05-29
年龄: 46
帖子: 35
声望力: 17 ![]() |
![]()
Matlab中的逻辑运算"&&"与"&","||"与"|"的区别是怎么样的?
|
![]() |
![]() |
![]() |
#2 |
普通会员
注册日期: 2009-02-22
帖子: 91
声望力: 18 ![]() |
![]()
& Element-wise Logical AND.
A & B is a matrix whose elements are logical 1 (TRUE) where both A and B have non-zero elements, and logical 0 (FALSE) where either has a zero element. A and B must have the same dimensions (or one can be a scalar). && Short-Circuit Logical AND. A && B is a scalar value that is the logical AND of scalar A and B. This is a "short-circuit" operation in that MATLAB evaluates B only if the result is not fully determined by A. For example, if A equals 0, then the entire expression evaluates to logical 0 (FALSE), regard- less of the value of B. Under these circumstances, there is no need to evaluate B because the result is already known. | Element-wise Logical OR. A | B is a matrix whose elements are logical 1 (TRUE) where either A or B has a non-zero element, and logical 0 (FALSE) where both have zero elements. A and B must have the same dimensions (or one can be a scalar). || Short-Circuit Logical OR. A || B is a scalar value that is the logical OR of scalar A and B. This is a "short-circuit" operation in that MATLAB evaluates B only if the result is not fully determined by A. For example, if A equals 1, then the entire expression evaluates to logical 1 (TRUE), regard- less of the value of B. Under these circumstances, there is no need to evaluate B because the result is already known. 望有帮助!!! |
![]() |
![]() |