& 和有什么不一样和&&在 MATLAB 中? [英] What's the difference between & and && in MATLAB?

查看:31
本文介绍了& 和有什么不一样和&&在 MATLAB 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MATLAB 中的 &&& 逻辑运算符有什么区别?

What is the difference between the & and && logical operators in MATLAB?

推荐答案

单符号 &是逻辑 AND 运算符.双与号 &&又是一个采用短路行为的逻辑 AND 运算符.短路只是意味着仅当结果不是由第一个操作数(左侧)完全确定时才评估第二个操作数(右侧)

The single ampersand & is the logical AND operator. The double ampersand && is again a logical AND operator that employs short-circuiting behaviour. Short-circuiting just means the second operand (right hand side) is evaluated only when the result is not fully determined by the first operand (left hand side)

A &B(评估A和B)

A & B (A and B are evaluated)

A & &B(仅当 A 为真时才评估 B)

A && B (B is only evaluated if A is true)

这篇关于& 和有什么不一样和&&在 MATLAB 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆