matlab web server安装配置过程

来源:互联网 发布:java 数组添加元素 编辑:程序博客网 时间:2024/06/04 19:24

作者:刘晓兵

环境:        windows xp
开发工具:    matlab 7.1
网站架构:    IIS 5.1 (我的win xp是简化版的,装IIS 6.0差很多DLL文件,就只好装IIS 5.1了)
(网站用Apache架构也是可以实现的!)

 



1、安装MATLAB,五分钟就能搞定
安装的时候有两个选项(typical和custom),选择custom,也就是自定义需要安装的组件,以确保安装matlab web server组件
matlab 7.1注册码:
PLP:14-24872-36179-32308-22113-61986-33825-00564-45479-60426-10395-51330-
19488-62201-37785-19497-45389-18974-51073-03706-04875-59691-49786-28969-
00719-61582-14402-53787-33213-56814-33775-57022-14254-56498



2、安装IIS 5.1 (IIS 6.0 当然更好)可以参考http://zhidao.baidu.com/question/39968979.html
装好后在
开始->设置->控制版面->管理工具->Internet 信息服务
可以设置网站的权限等问题



3、配置
我的网站根目录是C:/Inetpub/wwwroot/,
MATLAB的安装目录是:C:/Program Files/MATLAB71
MATLAB的webserver所需要的.m文件在C:/Program Files/MATLAB71/toolbox/webserver/wsdemos/
下面讲到的根据自己的实际情况更改即可

网站根目录下创建cgi-bin、icons两个文件夹(需要赋予读写权)
cgi-bin文件夹只需包含matweb.conf和matweb.exe两个文件
这两个文件的来源:MATLAB的安装目录下toolbox/webserver/wsdemos/可以找到,copy过来就行
同样,将toolbox/webserver/wsdemos里面的几张图片拷到icons文件夹里(图片不烤也没关系,只是网页里面的预设图片无法显示,但不影响程序的运行)
toolbox/webserver/wsdemos文件夹下面的所有HTML文件复制到网站根目录下C:/Inetpub/wwwroot/
(主要是些例子,安装MATLAB的时候它提供了四个例子)

修改C:/Inetpub/wwwroot/cgi-bin/下的matweb.conf文件
将已有的.m文件名都加到这里面
实例(每增加一个文件,需要添加如下三行)
[webmagic]    /*.m对应的文件名,用方括号括起来*/
mlserver=10.10.19.162    /*你的服务器的ip*/
mldir=C:/Inetpub/wwwroot/icons      /*图片存放的绝对路径,也就是上面在网站根目录下创建的文件夹icons的路径*/

ok,在浏览器里测试一下http://10.10.19.162/

 

 


******************************************************
最重要的,自己做一个例子(无参数的三角函数图像):
1、在网站根目录C:/Inetpub/wwwroot/下新建一个test1.html文件(内容见附件)
2、修改C:/Inetpub/wwwroot/cgi-bin/下的matweb.conf文件:
加上如下三行:
[test]
mlserver=10.10.19.162
mldir=C:/Inetpub/wwwroot/icons

3、在MATLAB安装目录toolbox/webserver/wsdemos下创建test.m和test2.html两个文件(见附件)
ok,在浏览器里测试http://10.10.19.162/test1.html,是否有你想看到的效果呢!
******************************************************


 

test.m内容

function PageString = test(InputSet, OutFile)
cd(InputSet.mldir);
wscleanup('wsrml*.jpeg', 1);
% setup to create a jpeg file
Fig = figure('visible','off');
x=[0:0.5:360]*pi/180;
plot(x,sin(x),x,cos(x));
%Adjust size图像大小控制++++++++++++++++++++++++++++++++++++++++++
%修改[]里面的后两个参数
pos = get(gcf, 'position');
pos(3) = 380;
pos(4) = 310;
set(gcf, 'Position', pos, 'PaperPosition', [.25 .25 10 7]);
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
PlotFile = sprintf('wsr%s.jpeg', InputSet.mlid);
drawnow;
wsprintjpeg(Fig, PlotFile);
close(Fig);
templatefile = which('test2.html');
if ( exist('OutFile','var') == 1 )
  s.GraphFileName = [ PlotFile];
  PageString = htmlrep(s, templatefile, OutFile);
else
  s.GraphFileName = ['/icons/' PlotFile];
  PageString = htmlrep(s, templatefile);
end


 

test1.html内容

<!-- $Revision: 1.2 $ -->
<html>
<head>
<title>matlab web server test</title>
</head>
<body bgcolor="#FFFFFF">
<br><br>
<div align="center"><font color="#000000" size="4" face="Arial">
<i>this is just a test file without aplications</i></font></div>
<br><br>
<div align="center"><font color="#000000" size="4" face="Arial">
<i>just click here to submit</i></font></div>
<div align="center">
<form action="/cgi-bin/matweb.exe" method="POST" target="outputwindow">
    <input type="hidden" name="mlmfile" value="test">
    <p><input type="submit" name="Submit" value="Submit">
</form>
</div>
</body>
</html>


 

test2.html内容

<!-- $Revision: 1.1 $ -->
<html>
<body bgcolor="#FFFFFF">
<br>
<p align="center">
<img border=0 src="$GraphFileName$">
</p>
</body>
</html>

 

 

原创粉丝点击