【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.
  
  
  • | 表示或,可对矩阵操作
  • ||同样表示或,但是更智能一点,只能对标量操作
  • 举个例子:A||B,如果A为真,则A||B就为真,不判断B真假
  • ~表示非
  • &表示与,可对矩阵操作
  • &&也表示与,只能对标量操作
  • 举个例子:A&&B,如果A为假,则A&&B为假,不判断B真假
  • ...:一般在编辑器里一行代码太长写不下了,用...表示续行,下一行的代码和上一行是连着的。但在字符串里不能这样。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值