haibaraxx的个人博客分享 http://blog.sciencenet.cn/u/haibaraxx

博文

Matlab: relational and logical operators

已有 2445 次阅读 2016-8-23 23:45 |个人分类:Matlab|系统分类:科研笔记| and, LOGICAL, operators, RELATIONAL

10==20

-> 0 % if it is false, it returns 0.

10<20

-> 1 % if it is true, it returns 1.

x=(16*64>1000)+9

-> 10 % x=1+9.

y=16*64>1000+9

-> 1 % arithmetic operators has higher precedence than relational&logical operators. 16*64>1000+9 is true, i.e. 1.

10==20 && 10<20

-> 0 % false && true

10==20 || 10<20

-> 1 % false || true

1 && 2

-> 1 % nonzero && nonzero

0 &&1

-> 0 % zero && nonzero

0 || 0

-> 0 % nonzero || nonzero

~ (1 && 2) || (0 || 0)

-> 0 % ~ 1 || 0 -> 0 || 0 -> 0

logical operators for matrix:

~[1 pi 0 3]

-> [0 0 1 0]

[1 2 pi 0 3] & [pi 4 0 9 8] % single &

-> [1 1 0 0 1]

[1 2 pi 0 3] | [pi 4 0 0 8] % single |

-> [1 1 1 0 1]

2 & [1 2; 0 3] % single &

-> [1 1; 0 1]

2 | [1 2; 0 3] % single |

-> [1 1; 1 1]






https://wap.sciencenet.cn/blog-3031432-998280.html

上一篇:好为人师者请绕行
下一篇:国外的博客scienceblog
收藏 IP: 134.1.1.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-5-21 03:31

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部