MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [MATLAB基础] Matlab中的逻辑运算"&&"与"&","||"与"|"的区别 (https://www.labfans.com/bbs/showthread.php?t=8685)

drosophilia 2009-05-28 15:10

Matlab中的逻辑运算"&&"与"&","||"与"|"的区别
 
Matlab中的逻辑运算"&&"与"&","||"与"|"的区别是怎么样的?

TTT_IOU 2009-05-29 23:43

回复: Matlab中的逻辑运算"&&"与"&","||"与"|"的区别
 
& 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.
望有帮助!!!


所有时间均为北京时间。现在的时间是 06:24

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.