15-2 ??????

@몺[BBB|hBuΦbƭȸơAڭ̬JMгyFhANӭnwqo@ǦP˾AΩhާ@򥻹B覡CFتAڭ̥iHǥѩwqXӯS禡AӨϤ@B⤸]Overloading^LC

Aڭ̩wqh[kAi plus.m 禡ӹFAepUG

Example 1: 15-ɦV{]p/@polynom/plus.mfunction r = plus(p, q) % POLYNOM/PLUS Implement p + q for polynoms. p = polynom(p); q = polynom(q); k = length(q.c) - length(p.c); r = polynom([zeros(1,k) p.c] + [zeros(1,-k) q.c]);

禡ˬdJѼƬO_hAYOANনhAo˪@kڭ̯VMhMVqӶi[kAҦpڭ̥iHϥΡup + [1, 1]vӥNNh p [W x+1C

hŪkAhi minus.m 禡ӹFAepUG

Example 2: 15-ɦV{]p/@polynom/minus.mfunction r = minus(p,q) % POLYNOM/MINUS Implement p - q for polynoms. p = polynom(p); q = polynom(q); k = length(q.c) - length(p.c); r = polynom([zeros(1,k) p.c] - [zeros(1,-k) q.c]);

FoӨ禡Aڭ̴NiHӴզh[kApUG

Example 3: 15-ɦV{]p/polyPlusMinus01.mp = polynom([3 4 2 1]); q = polynom([-1, 2]); r = p + q s = r + [2, 3] r = 3*x^3 + 4*x^2 + 1*x^1 + 3*x^0 s = 3*x^3 + 4*x^2 + 3*x^1 + 6*x^0

ۧڭ̥iHᤩkPkwhiBAһݩwq禡O mtimes.m mrdivide.mAeOCXpUG

Example 4: 15-ɦV{]p/@polynom/mtimes.mfunction r = mtimes(p, q) % POLYNOM/MTIMES Implement p*q for polynoms. p = polynom(p); q = polynom(q); r = polynom(conv(p.c, q.c));

Example 5: 15-ɦV{]p/@polynom/mrdivide.mfunction [q, r] = mrdivide(a, b) % POLYNOM/MRDIVIDE Implement a/b for polynoms. a = polynom(a); b = polynom(b); [q, r] = deconv(a.c, b.c); q = polynom(q); r = polynom(r);

FoǨ禡Aڭ̴NiHhi[|hBFAШUCdҡG

Example 6: 15-ɦV{]p/polyTimesDivide01.mp = polynom([1, 1]); q = polynom([1, 2]); r = (p+1)*(q+2) [a, b] = r/[1, 1] r = 1*x^2 + 6*x^1 + 8*x^0 a = 1*x^1 + 5*x^0 b = 0*x^2 + 0*x^1 + 3*x^0

bezdҤAڭ̨ϥ mrdivide.m Ψөwqukv]Ҧp p/q^AA]iHϥ mldivide.m өwquv]Ҧpp\q^C~AA٥iHϥ mpower.m өwqAҦpp^nCMATLAB B⤸P禡YAШUC

B⦡M-ɮ
a+bplus(a,b)G[k]Binary addition^
+auplus(a)@[k]Unary plus^
a-bminus(a,b)Gk]Binary subtraction^
-auminus(a)@k]Unary minus^
a.*btimes(a,b)露k]Element-wise multiplication^
a*bmtimes(a,b)x}k]Matrix multiplication^
a./brdivide(a,b)露k]Right element-wise division^
a.\bldivide(a,b)露]Left element-wise division^
a/bmrdivide(a,b)x}k]Matrix right division^
a\bmldivide(a,b)x}]Matrix left division^
a.^bpower(a,b)露]Element-wise power^
a^bmpower(a,b)x}]Matrix power^
a < blt(a,b)p]Less than^
a > bgt(a,b)j]Greater than^
a <= ble(a,b)pε]Greater than or equal to^
a >= bge(a,b)jε]Less than of equal to^
a~=bne(a,b)]Not equal to^
a==beq(a,b)]Equality^
a&band(a,b)޿ AND]Logical AND^
a|bor(a,b)޿ OR]Logical OR^
~anot(a)޿ NOT]Logical NOT^
a:d:b
a:b
colon(a,d,b)
colon(a,b)
_B]Colon operator^
a'ctranspose(a)@mƼm]Complex conjugate transpose^
a.'transpose(a)x}m]Matrix transpose^
ܪùdisplay(a)ܪ󪺤k]Display method^
[a b]horzcat(a, b, ...)걵]Horizontal concatenation^
[a; b]vertcat(a, b, ...)걵]Vertical concantenation^
a(s1, s2, ..., sn)subsref(a, s)HUжis]Subscripted reference^
a(s1, s2, ..., sn)=bsubsasgn(a, s, b)HUжiw]Subscripted assignment^
b(a)subsindex(a)UЯޡ]Subscript index^

MATLAB{]pGig