14-2 ��������������?

MATLAB YB⤸]Relational Operators^UCءG

YB⤸
==
~=
< p
<=
> j
>=

MATLAB YB⤸`OHx}露覡@BAҦpG

Example 1: 14-MATLABB⤸/greaterThan01.ma = [1 2; 3 4]; b = [1 3; 2 4]; c = a>b c = 0 0 1 0

ѤWҥiAY a(i, j) > b(i, j)Ah c(i, j) Ȭ 1]ܡuuvΡuߡv)A_hY 0]ܡuvΡuߡv)CMATLAB YB⤸䴩¶qi}AҦpG

Example 2: 14-MATLABB⤸/greaterThan02.ma = [1 2; 3 4]; c = a>2 c = 0 0 1 1

~Aڭ̥iHNYB⤸Ǧ^ 0-1 x}]Ȭ 0 1^Ӷix}ޡ]Indexing^AöiӧXY󪺯x}AҦpADXb a x}A a(i, j) >= b(i, j) AiJpUG

Example 3: 14-MATLABB⤸/findElement01.ma = [10 20; 30 40]; b = [10 30; 20 40]; c = a>=b; d = a(c) d = 10 30 40

bWҤAiϥ a(a >= b) ӨDoסC~AbWҤAx} C O@ӥ޿B]U`^Ҳͪ޿ޯx}A]iΩ a ޿ޡ]Logic Indexing^C@ӨAYni޿ޡA̦nNޯx}gL logical OBzAHKͺøqCHWҦӨAa([0,1;1,0]) |Ϳ~TATgkӬO a(logical([0,1;1,0]))C

t@ӱ`ΨӴMx}OO findAiǦ^DsޡAҦpG

Example 4: 14-MATLABB⤸/find01.mx = [0 1 2; 0 0 3]; index = find(x) index = 3 5 6

bWҤAindex N x @ީΤUСAiԨѲĤEux}BzMBvĤ@`ux}ީΤUСvA x(index) hODsҧΦVqCYnXY󪺤GީΤUСAiJpUG

Example 5: 14-MATLABB⤸/find02.mx = magic(3); [idx1, idx2] = find(x>5) idx1 = 1 3 1 2 idx2 = 1 2 3 3

bWҤAidx1 M idx2 OOŦX󤧯x}Cޡ]Row Index^ΦC]Column Index^C]AYQ find OAiHܧ֦aXŦXY󦡪CҦpGDX 7 M 11 AiJpUG

Example 6: 14-MATLABB⤸/find03.mx = magic(5); x(find(7<x & x<11)) ans = 10 8 9

䤤 & N޿誺 ANDANbU`СC


MATLAB{]pGJg