18-5 �����ɮת�Ū��

MATLAB ¤]¥i¥Hª½±µÅª¨úºô¸ô¤WªºÀɮסA³q±`§Ú­Ì¬O±Ä¥Î URL¡]Universal Resource Locator¡^ªº¤è¦¡¨Ó«ü©w³o¨Çºô¸ô¤WªºÀɮסA¨Ò¦p¡G

¦b¤U¦C½d¨Ò¤¤¡A§Ú­Ì¨Ï¥Î urlread «ü¥O¨ÓŪ¨úµ§ªÌ¦b²MµØ¤j¾Ç¸ê°T¨tªº­º­¶¡A¨Ã±Nµ²ªG«ü©w¨ì¦r¦êÅÜ¼Æ contents¡A¦p¤U¡G

Example 1: 18-ÀÉ®×Ū¼g/urlread01.mcontents = urlread('http://www.cs.nthu.edu.tw/~jang'); disp(contents);<HTML> <HEAD> <META http-equiv="Refresh" content="0; URL=http://neural.cs.nthu.edu.tw/jang"> </HEAD> <BODY> The link you just clicked is obsolete.<br> You are being transported automatically to Roger Jang's current homepage at <a href="http://neural.cs.nthu.edu.tw/jang"> http://neural.cs.nthu.edu.tw/jang</a>. </BODY> </HTML>

§Ú­Ì¤]¥i¥Hª½±µ¦bŪ¨úºô­¶«á¡A´NÀx¦s¨ì¥»¾÷µwºÐ¤¤¡A³o®É¥i¥Î urlwrite «ü¥O¡A½d¨Ò¦p¤U¡G¨Ò¦p¡G

Example 2: 18-ÀÉ®×Ū¼g/urlread02.mtempFile = [tempname, '.html']; % «ü©w¼È¦sÀÉ®× urlwrite('http://www.google.com.tw', tempFile); % ±Nºô­¶¤º®e¼g¨ìÀÉ®× dos(['start ', tempFile]); % ¶}±Ò¦¹ÀÉ®×

¦b¤W­z½d¨Ò¤¤¡A§Ú­Ì±N www.google.com.tw ªººô­¶¤º®e¼g¨ì¤@­Ó¼È¦sÀɮסAµM«á¦A¨Ï¥ÎÂsÄý¾¹¶}±Ò¦¹ÀɮסC

¥t¤@­Ó©Mºô¸ô¬ÛÃöªº¥\¯à«h¬O±Hµo¹q¤l¶l¥ó¡A¥i¥Ñ sendmail «ü¥O¨Ó¹F¦¨¡AÁöµM³o­Ó¥\¯à©MÀÉ®×Ū¼g¨S¦³ª½±µÃö«Y¡A¦ý¦]¬°¦¹«ü¥O¬O©ñ¦b

{matlab®Ú¥Ø¿ý}\toolbox\matlab\iofun\

©Ò¥H§Ú­Ì¤]¦b³o¸Ì¤@¨Ö»¡©ú¡CSendmail «ü¥Oªº¥Îªk¦p¤U¡G

sendmail(TO, SUBJECT, MESSAGE, ATTACHMENTS)

¨ä¤¤

¥H¤U³o­Ó½d¨Ò¨Ï¥Î sendmail ¨Ó±Hµo¹q¤l¶l¥ó¦Ü¨â¦ì±µ¦¬±b¸¹¡G

Example 3: 18-ÀÉ®×Ū¼g/sendmail01.mto = {'email1@aaa.bbb.ccc', 'email2@aaa.bbb.ccc'}; to = {'jang@cs.nthu.edu.tw'}; subject = 'Test email from a MATLAB program'; message = ['This is a test email sent via', 10, ' sendmail.']; attachment = {'c:\windows\matlab.ini'}; sendmail(to, subject, message, attachment);Error in running sendmail01! (Logged to error.log)

¦b°õ¦æ¤W­z½d¨Ò¤§«e¡A½Ð°È¥²±N to ªº¤º®e§ï¬°§A¦Û¤v¥»¨­ªº¹q¤l¶l¥ó¡A§_«h§A´NµLªk¦¬¨ì¦¹¶l¥ó¡A¤]´NµLªk½T»{¦¹µ{¦¡½Xªº¥¿½T©Ê¤F¡C

Hint
­Y­n¦b¶l¥ó¤º®e¥[¤J´«¦C¡A¥i¥H¨Ï¥Î ASCII ½X¡u10¡v¡A¨Ò¦p¡Gmessage=[¡¦Sir:¡¦, 10, ¡¥This is a test¡¦]¡C


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