20-5 ���νd�ҤT�GMATLAB �{���X����

¦b§Ú­Ì¹êÅç«Ç¶i¦æ¬ã¨sªº¹Lµ{¤¤¡A¨C­Ó¤H³£·|¶}µo¬ÛÃöªº MATLAB µ{¦¡¡A¨Ã·J¾ã¦¨¤@­Ó­Ó¤u¨ã½c¡]Toolbox¡^¡A¥H«K¥L¤H¨Ï¥Î¡C¦ý¬O¦bµo®iªº¹Lµ{¤¤¡Aµ{¦¡½X±`±`»Ý­n­×§ï¡A¬°¤F¤è«KºÞ²z¡A§Ú­Ì§â¬ÛÃöªº»¡©ú¤]©ñ¦bµ{¦¡½X¤º¡A¦p¦ó¯à¤@¥Ø¤FµM¦a¬Ý¨ì³o¨Ç»¡©ú¡A¬O¤@¥ó«Ü­«­nªº¤u§@¡C

¦]¦¹§Ú¯S§O·Ç³Æ¤F¤@­Ó­Ó¤H¶}µoªº¤u¨ã½cªº web ¤¶­±¡A¯à°÷§Y®É¦a§ì¥X MATLAB µ{¦¡Àɮפºªº­«­n»¡©ú¡A¨Ã¦C¥X©óºô­¶¡C·íµM¡A­n¯à¨Ï¥Î³o­Ó¥\¯à¡A©Ò¦³µ{¦¡³]­pªÌ¦b¼¶¼g MATLAB µ{¦¡®É¡A¬ÛÃöªº»¡©ú¤å¦r¥²¶·²Å¦X¤@¨Ç³W½d¡A³o¨Ç³W½d¥i¨£¤U¦C½d¨Òºô­¶¦b³Ì©³³¡ªº»¡©ú¡G

Example¡]fileAccess/utility/index.asp¡^¡G

¦b¤W­zºô­¶¤¤¡A§Ú­Ì¨Ï¥Î JScript ¨Ó¤Î®É©â¨ú¥X¨Ó¨C¤@­Ó MATLAB ¨ç¦¡ªº»¡©ú¡A¨Ã·J¾ã¦bºô­¶¤W¡C¦P®É§Ú­Ì¤]®Ú¾Ú¨C¤@­ÓÀɮ׮榡ªº¤£¦P¡A¨Ó¤ÀÃþ¦¨¨ç¦¡Àɮס]Function Files¡^©M©³½ZÀɮס]Script Files¡^¡A¤À¶}Åã¥Ü¡C¦¹½d¨Òªº­ì©l½X¦p¤U¡G

­ì©lÀÉ¡]fileAccess/utility/index.asp¡^¡G¡]¦Ç¦â°Ï°ì«ö¨â¤U§Y¥i«þ¨©¡^
<%@language=JScript%>
<% title="Utility Toolbox: MATLAB µ{¦¡»¡©ú" %>
<%
function getMFileUsage(fileName){
	fso = new ActiveXObject("Scripting.FileSystemObject");
	fid=fso.OpenTextFile(fileName, 1);
	contents=fid.ReadAll();
	fid.Close();
	lines=contents.split("\n");
	output=new Object();

	// ====== Check if a function
	pattern=/^\s*function\s/i;
	line=lines[0];
	output.isFunction=false;
	if (line.match(pattern) != null)
		output.isFunction=true;

	// ====== Get H1 help
	pattern=/^%\s*(.*)/i;
	output.h1="";
	for (i=0; i<lines.length; i++)
		if (lines[i].match(pattern) != null){
			output.h1=RegExp.$1;
			break;
		}
	
	// ====== Usage line
	pattern=/^%\s*Usage:\s*(.*)/i;
	output.usage="";
	startLine=-1;
	for (i=0; i<lines.length; i++)
		if (lines[i].match(pattern) != null){
			output.usage=RegExp.$1;
			startLine=i;
			break;
		}

	// ====== Argument documentation
	pattern=/^%\s*(.*)/i;
	output.argumentDoc="";
	if (startLine>=0)
		for (i=startLine+1; i<lines.length; i++)
			if ((lines[i].match(pattern) != null) && (RegExp.$1 != ""))
				output.argumentDoc = output.argumentDoc + "\\n" + RegExp.$1;
			else
				break;

	// ====== Return the final output
	return(output);
}
%>

<html>
<head>
	<title><%=title%></title>
	<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=big5">
	<meta HTTP-EQUIV="Expires" CONTENT="0">
	<style>
		td {font-family: "¼Ð·¢Åé", "helvetica,arial", "Tahoma"}
		A:link {text-decoration: none}
		A:hover {text-decoration: underline}
	</style>
</head>

<body background="/jang/graphics/background/yellow.gif">
<font face="¼Ð·¢Åé">
<h2 align=center><%=title%></h2>
<h3 align=center><a target=_blank href="/jang">±i´¼¬P</a></h3>
<hr>

<h3><img src="/jang/graphics/dots/redball.gif">²­n»¡©ú</h3>
<blockquote>¥»¤u¨ã½c´£¨Ñ MATLAB ±`¥Îªº¤½¥Î¨ç¼Æ¡A¤]Åwªï¤j®a°^Äm¡C</blockquote>

<%
fso = new ActiveXObject("Scripting.FileSystemObject");
fullPath = Server.MapPath(".");

webPath=Request.ServerVariables("PATH_INFO");
realPath=Request.ServerVariables("PATH_TRANSLATED");
rarWebPath=fso.GetParentFolderName(webPath)+".rar";
rarRealPath=fso.GetParentFolderName(realPath)+".rar";
rarFile=fso.GetFileName(fso.GetParentFolderName(realPath))+".rar";
if (fso.FileExists(rarRealPath)){
%>
<h3><img src="/jang/graphics/dots/redball.gif">¾ã­Ó¥Ø¿ýÀ£ÁYÀÉ¡G<a href="<%=rarWebPath%>"><%=rarFile%></a></h3>
<%}%>

<h3><img src="/jang/graphics/dots/redball.gif">»Ý­n¦@¥Îªº¤u¨ã½c</h3>
<blockquote>µL¡C</blockquote>

<!== ¦C¥X¨ç¼Æ -->
<h3><img src="/jang/graphics/dots/redball.gif">¨ç¼Æ¦Cªí</h3>
<table border=1 align=center>
<tr>
<th>ÀɮצWºÙ<th>³æ¦C»¡©ú<th>¨ç¼Æ¥Îªk<th>Àɮפj¤p
<%
fd = fso.GetFolder(fullPath);
fc = new Enumerator(fd.Files);
for (; !fc.atEnd(); fc.moveNext()){
	fileName=fc.item()+"";
	ext=fso.GetExtensionName(fileName);
	if ((ext=="m") || (ext=="M")){
		f = fso.GetFile(fileName);
		out=getMFileUsage(fileName);
		if (out.isFunction){
			Response.write("\n<tr>\n");
			Response.write("<td><a target=_blank href=\"" + f.Name + "\">" + f.Name + "</a></td>");
			Response.write("<td>" + out.h1 + "&nbsp;</td>");
			doc=out.argumentDoc;
			doc=doc.replace(/"/g, "\\\"");		// ±N¦r¦ê­ì¦³ªº " ¥N´«¦¨ \"
			doc=doc.replace(/'/g, "\\\'");		// ±N¦r¦ê­ì¦³ªº ' ¥N´«¦¨ \'
			if (doc!="")
				Response.write("<td><a href='javascript:alert(\"" + doc + "\")'>" + out.usage + "</a>&nbsp;</td>");
			else
				Response.write("<td>" + out.usage + "</td>");
			Response.write("<td align=right>" + f.Size + "</td>");
		}
	}
}
%>
</table>

<!== ¦C¥X©³½Z -->
<h3><img src="/jang/graphics/dots/redball.gif">©³½Z¦Cªí</h3>
<table border=1 align=center>
<tr>
<th>ÀɮצWºÙ<th>³æ¦C»¡©ú<th>Àɮפj¤p
<%
fd = fso.GetFolder(fullPath);
fc = new Enumerator(fd.Files);
for (; !fc.atEnd(); fc.moveNext()){
	fileName=fc.item()+"";
	items=fileName.split(".");
	ext=items[items.length-1];
	if ((ext=="m") || (ext=="M")){
		f = fso.GetFile(fileName);
		out=getMFileUsage(fileName);
		if (!out.isFunction){
			Response.write("\n<tr>\n");
			Response.write("<td><a href=\"" + f.Name + "\">" + f.Name + "</a></td>");
			Response.write("<td>" + out.h1 + "&nbsp;</td>");
			Response.write("<td align=right>" + f.Size + "</td>");
		}
	}
}
%>
</table>

<!== ¦C¥X¨ä¥LÀÉ®× -->
<h3><img src="/jang/graphics/dots/redball.gif">¨ä¥LÀÉ®×</h3>
<table border=1 align=center>
<tr>
<th>ÀɮצWºÙ<th>Àɮפj¤p
<%
fd = fso.GetFolder(fullPath);
fc = new Enumerator(fd.Files);
for (; !fc.atEnd(); fc.moveNext()){
	fileName=fc.item()+"";
	items=fileName.split(".");
	ext=items[items.length-1];
	if ((ext!="m") && (ext!="M")){
		f = fso.GetFile(fileName);
		Response.write("\n<tr>\n");
		Response.write("<td><a href=\"" + f.Name + "\">" + f.Name + "</a></td>");
		Response.write("<td align=right>" + f.Size + "</td>");
	}
}
%>
</table>

<h3><img src="/jang/graphics/dots/redball.gif">¨ä¥L»¡©ú¡G¦p¦ó«Ø¸m§Aªº¤u¨ã½c¨ÃÅý§O¤H¨Ï¥Î</h3>
<ul>
<li>½Ð±N¥»¥Ø¿ýªº index.asp ©ñ¸m¨ì§Aªº toolbox ¥Ø¿ý¡A¦P®É¦b IIS ªº¡u¥Ø¿ý¹w³]¤å¥ó¡v¥[¤J index.asp¡A¦¹®É·í§O¤H¸g¥ÑÂsÄý¾¹³s±µ¨ì§Aªº toolbox ¥Ø¿ý¡A¦¹ index.asp §Y·|¦Û°Ê§ì¥X¦U­Ó MATLAB µ{¦¡½Xªº¬ÛÃö»¡©ú¡A¨Ã¥ß¨èÅã¥Ü¦bºô­¶¤W¡C
<li>¬°¤FÅý index.asp ¯à°÷¥¿½T¦a§ì¥X¬ÛÃö»¡©ú¡A§Aªº MATLAB µ{¦¡½X¥²¶·²Å¦X¤U¦C³W½d¡G
	<ul>
	<li>­Y¬O¨ç¼Æ¡A²Ä¤@¦Cªº²Ä¤@­Ó­^¤å¦r¥²¶·¬O¡ufunction¡v¡C
	<li>µL½×¨ç¼Æ©Î¬O©³½Z¡A²Ä¤@¦Cµù¸Ñ·|³Q§ì¥X¨Ó¡A¸m©ó¡u³æ¦C»¡©ú¡vÄæ¦ì¤º¡C
	<li>²Ä¤@¦C±a¦³¡uUsage: ¡vªºµù¸Ñ¦C¡A·|³Q§ì¥X¨Ó¡A¸m©ó¡u¨ç¼Æ¥Îªk¡v¡C
	<li>¡uUsage: ¡v¤§«áªº³sÄòµù¸Ñ¦C¡A³£·|³Qµø¬°¿é¤J©M¿é¥X¤Þ¼Æªº»¡©ú¡A·í§AÂI¤U¥h¨ç¼Æ¥Îªk®É¡A·|¥Hĵ§iµøµ¡ªº¤è¦¡¸õ¥X¨Ó¡C
	</ul>
<li>¬°¨Ï¨ç¼Æ«K©ó¥L¤H­«½Æ¨Ï¥Î¡A½Ð¦b¼¶¼g¨ç¼Æ®É¡Aª`·N¤U¦C¨Æ¶µ¡G
	<ul>
	<li>¨C­Ó¨ç¼Æ¥²¶·¼Ð¦¡§@ªÌ¤j¦W©M­×§ï¤é´Á¡A¥H¥Ü­t³d¡C
	<li>©Ò¦³ªº»¡©ú¡A¤]¥i¥H¨Ï¥Î¤¤¤å¡A°È¥²¥H²M´·¬°²Ä¤@¥Ø¼Ð¡C
	<li>¬°«OÅ@¥»¹êÅç«Çªº´¼¼z°]²£Åv¡A©Ò¦³ªº mex ©Î dll Àɮתº­ì©l C µ{¦¡½X¡A½Ð¤£­n©ñ¤J¦¹¥Ø¿ý¡C
	</ul>
<li>¦pªG toolbox ¸ô®|¬O /jang/toolbox/utility ®É¡Aindex.asp ·|¦Û°Ê¥h§ä /jang/toolbox/utility.asp ¨Ã±N¤§µø¬°¾ã­Ó toolbox ªºÀ£ÁYÀÉ¡C¡]¦]¦¹¦pªG§A¦³§ó·s toolbox¡A°O±o­n­«·sÀ£¤@¥÷ .rar ÀɮסA¨Ã©ñ¦b¦P¤@¼h¥Ø¿ý¡C¡^
<li>³Ì«á¡A°O±o­n§R°£²{¦b§A©Ò¬Ý¨ìªº»¡©ú¤å¦r¡A¨Ã­×§ï¥»­¶ªº¼ÐÃD¤å¦r¡B§@ªÌ¤j¦W¡B¤u¨ã½c²­n»¡©ú¡B»Ý­n¦@¥Îªº¤u¨ã½cµ¥µ¥¡C
</ul>

<hr>

<script language="JavaScript">
document.write("Last updated on " + document.lastModified + ".")
</script>

<a href="/jang/sandbox/asp/lib/editfile.asp?FileName=<%=Request.ServerVariables("PATH_INFO")%>"><img align=right border=0 src="/jang/graphics/invisible.gif"></a>
</font>
</body>
</html>


JScript µ{¦¡³]­p»PÀ³¥Î¡G¥Î©ó¦øªA¾¹ºÝªº ASP Àô¹Ò