Hint
§A¥²¶·±N¥]§t¦¹ @polynom ªº¤W¼h¥Ø¿ý¥[¨ì MATLAB ªº·j´M¸ô®|«á¡A¤~¥i¥H¦b¥ô·N³B¨Ï¥Î»P polynom ¬ÛÃöªºª«¥ó©Î¤èªk¡C

Example 1: 15-ª«¥ó¾É¦Vµ{¦¡³]­p/@polynom/polynom.mfunction poly = polynom(vec) %POLYNOM Polynomial class constructor % poly = POLYNOM(vec) creates a polynomial object from the given vector vec % which contains the coefficients of the descending-order polynomial. if isa(vec, 'polynom') % ­Y vec ¤w¸g¬O polynom ª«¥ó¡A«hª½±µ³]©w¦¨¿é¥X poly = vec; else poly.c = vec(:).'; % ±N¦V¶q³]©w¦¨ poly ªº«Y¼Æ poly = class(poly, 'polynom'); % ±N poly ¥[«ù¦¨ polynom ª«¥ó end

±q¤W­zµ{¦¡½X¥i¥H¬Ý¥X¡G

¦pªG¿é¤J¬O¤@­Ó¦V¶q¡A³o´N¬O¦h¶µ¦¡ªº«Y¼Æ¡]­°¾­±Æ¦C¡^¡A§Ú­Ì±N¦¹«Y¼Æ³]©wµ¹ poly.c¡A³Ì«á¨Ï¥Î class ¨ç¦¡±N poly ÅÜ¼Æ¥[«ù¦¨ polynom ª«¥ó¡C

¦pªG¿é¤J vec ¤w¸g¬O¤@­Ó polynom ª«¥ó¡A«hª½±µ¿é¥X¦¹ª«¥ó¡C¡]isa(vec, ¡¥polynom¡¦) ¥Î¨ÓÀË¬d vec ¬O§_¬O¤@­Ó polynom ª«¥ó¡C¡^

Example 2: 15-ª«¥ó¾É¦Vµ{¦¡³]­p/@polynom/display.mfunction display(poly) % POLYNOM/DISPLAY Display of a polynom disp(' '); disp([inputname(1),' = ']) disp(' '); disp([' ', polyAsString(poly)]) disp(' ');

Example 3: 15-ª«¥ó¾É¦Vµ{¦¡³]­p/@polynom/polyAsString.mfunction s = polyAsString(poly) % POLYNOM/POLYASSTRING String representation of a polynom degree=length(poly.c)-1; s = sprintf('%d*x^%d', poly.c(1), degree); for i=degree-1:-1:0 coef = poly.c(degree-i+1); if coef >=0 s=sprintf('%s + %d*x^%d', s, coef, i); else s=sprintf('%s - %d*x^%d', s, -coef, i); end end

Example 4: 15-ª«¥ó¾É¦Vµ{¦¡³]­p/test01.mp = polynom([3 4 2 1]) p = 3*x^3 + 4*x^2 + 2*x^1 + 1*x^0

Hint
¤W­zÅã¥Ü¨ç¦¡ÄÝ©ó¤@¯ëª«¥óªº¤º«ØÅã¥Ü¨ç¦¡¡A¨ä¥¦ªº»Pª«¥ó¬ÛÃöªº¨ç¦¡ÁÙ¦³¥[¡B´î¡B­¼¡B°£µ¥°ò¥»¹Bºâ¤¸¡A½Ð¨£¤U¤@¸»¡©ú¡C