## 14-2 ?¢ç??¨ç??‰ç”¨ç¨‹å?

mcc ¡Vm userFunc.m

14-matlab½sÄ¶¾¹/myEigValue.mfunction eigValue = myEigValue(mat) %myEigValue: Generate the eigenvalues of the given matrix % Roger Jang, 20080210 if (isstr(mat)) % ­Y¿é¤J¬O¦r¦ê¡AÂà¦¨¼Æ­È mat=eval(mat); end [a, b] = eig(mat); eigValue=diag(b); disp(eigValue); % Åã¥Ü©T¦³­È eigenValue

myEigValue(magic(5));

Hint

¥Ñ©ó§Ú­Ì­n±N myEigValue.m Âà´«¦¨ myEigValue.exe¡A©Ò¥H¦³¤@¨Ç²Ó¸­n¯S§O¤p¤ß¡G

2. myEigValue.m ¥²¶·¨Ï¥Î disp µ²ªG¦L¦b¿Ã¹õ¤W¡A¥H¤è«K myEigValue.exe ¨Ó¦L¥X¦P¼Ëªºµ²ªG¡C

mcc ¡Vm myEigValue.m

Hint
¡u-m¡v¥Nªí¨Ï¥Î¥¨¶°¡]Macro¡^¨Ó²£¥Í¿W¥ßÀ³¥Îµ{¦¡¡A³o¬O¤@¯ë¹w³]ªº¿ï¶µ¡C

myEigValue.exe magic(5)

myEigValue.exe "[1 2 3; 3 2 1; 1 1 1]" §Ú­Ì¥i¥H±N¤W­z¬yµ{¾ã²z¦¨¤@­Ó³æ¤@ªº½d¨Ò¡G

Example 1: 14-matlab½sÄ¶¾¹/mcc01.mfprintf('MATLAB version=%s\n', version); if ~exist('myEigValue'), mkdir('myEigValue'); end fprintf('Compiling myEigValue.m...\n'); tic; mcc -m myEigValue.m -d myEigValue; fprintf('Time for compiling = %g sec\n', toc); fprintf('Running DOS command: myEigValue\\myEigValue.exe magic(5)\n'); !myEigValue\myEigValue.exe magic(5) fprintf('Running DOS command: myEigValue\\myEigValue.exe "[1 2 3; 3 2 1; 1 1 1]"\n'); !myEigValue\myEigValue.exe "[1 2 3; 3 2 1; 1 1 1]" MATLAB version=7.14.0.739 (R2012a) Compiling myEigValue.m... DEMO Compiler license. The generated application will expire 30 days from today, on Sat Sep 15 20:06:02 2012. Time for compiling = 45.2777 sec Running DOS command: myEigValue\myEigValue.exe magic(5) 65.0000 -21.2768 -13.1263 21.2768 13.1263 Running DOS command: myEigValue\myEigValue.exe "[1 2 3; 3 2 1; 1 1 1]" 5.0000 -1.0000 0.0000

¦b¤W­z½d¨Ò¤¤¡A§Ú­Ì¦h°µ¤F´X¥ó¨Æ¡A¨ÓÅý¾ã­ÓÀÉ®×¥Ø¿ýµ²ºc°®²b¤@¨Ç¡G
1. ¦pªG¿é¥X¥Ø¿ý myEigValue ¤£¦s¦b¡A§Ú­Ì¥ý«Ø¥ß³o­Ó¥Ø¿ý¡C