14-3 �޿�B�⤸

MATLAB ªºÅÞ¿è¹Bºâ¤¸¡]Logical Operators¡^¦@¦³¤TºØ¡G

ÅÞ¿è¹Bºâ¤¸»¡©ú
& AND
| OR
~ NOT

°ò¥»¤W¡A­Y¤@ÅܼƭȬ° 0¡A«hµø¬°¡u°°¡v¡]False¡^¡A§_«h§Yµø¬°¡u¯u¡v¡]True¡^¡A¨Ò¦p¡G

Example 1: 14-MATLABªº¹Bºâ¤¸/logical01.ma = [1 2 0 3 4 2 0]; b = [0 2 3 5 4 0 0]; andResult = a & b % AND ¹Bºâ orResult = a | b % OR ¹Bºâ notResult = ~a % NOT ¹Bºâ andResult = 0 1 0 1 1 0 0 orResult = 1 1 1 1 1 1 0 notResult = 0 0 1 0 0 0 1

¬ÛÃöªº«ü¥OÁÙ¦³ all ¤Î any¡A»¡©ú¦p¤U¡G

¨Ò¦p¡G

Example 2: 14-MATLABªº¹Bºâ¤¸/logical02.ma = [0 1 2 3]; result1 = all(a) retult2 = any(a) result3 = any(a<0) result1 = 0 retult2 = 1 result3 = 0

all ¤Î any «ü¥O¤]¥i¥H±µ¨ü¯x°}¿é¤J¡A¦¹®É¥L­Ì·|¹ï¨C¤@­Ó¦æ¦V¶q¶i¦æ¹Bºâ¡A¨Ò¦p¡G

Example 3: 14-MATLABªº¹Bºâ¤¸/logical03.ma = [1 2 3; 4 5 6]; output = all(a>2) output = 0 0 1


MATLABµ{¦¡³]­p¡G¤Jªù½g