Author: Liu Xiaobing
Environment: Windows XP
Development tools: MATLAB 7.1
Website architecture: IIS 5.1 (My Win XP is a simplified version. I had to install IIS 6.0 when installing many DLL files except IIS 5.1)
(The Apache architecture can also be used for websites !)
1. Install MATLAB, which can be completed in five minutes.
There are two options for installation (typical and custom). Select custom, which is the component to be installed, to ensure installation of the Matlab Web Server Component
MATLAB 7.1 registration code:
PLP: 14-24872-36179-32308-22113-61986-33825-00564-45479-60316-10395-51330-
19488-62201-37785-19497-45389-18974-51073-03706-04265-59691-49786-28969-
00719-61582-14402-53787-33213-56814-33775-57022-14254-56498
2, install IIS 5.1 (IIS 6.0 of course better) can refer to the http://zhidao.baidu.com/question/39968979.html
After installation
Start> Settings> control layout> Management Tools> Internet Information Service
You can set website permissions.
3. Configuration
The root directory of my website is C:/inetpub/wwwroot /,
The installation directory of MATLAB is: C:/program files/MATLAB 71.
The. M file required by the MATLAB WebServer is in C:/program files/MATLAB 71/toolbox/webserver/wsdemos/
You can change it according to your actual situation.
Create cgi-bin and icons folders under the root directory of the website (read/write permission is required)
Only the files matweb.confand matweb.exe must be included in the cgi-binfile folder.
The source of these two files: toolbox/webserver/wsdemos/Under the installation directory of MATLAB can be found, just copy it.
Likewise, copy several images in toolbox, Webserver, and wsdemos to the icons folder (it doesn't matter if the images are not baked, but the preset images in the webpage cannot be displayed, but it does not affect program running)
Copy all HTML files in the toolbox/webserver/wsdemos folder to C:/inetpub/wwwroot/Under the root directory of the website/
(Mainly for some examples, it provides four examples when installing MatLab)
Modify the matweb. conf file under C:/inetpub/wwwroot/cgi-bin/
Add the existing. M file names to this interface.
Instance (Add the following three lines for each added file)
[Webmagic]/*. M file name, enclosed in square brackets */
Mlserver = 10.10.19.162/* IP address of your server */
Mldir = C:/inetpub/wwwroot/icons/* absolute path for storing images, that is, the icons path of the folder created in the root directory of the website above */
OK. Test http: // 10.10.19.162/in the browser/
**************************************** **************
The most important thing is to make an example by yourself (a trigonometric function image without parameters ):
1. Create a New test1.html file under the website root directory c:/inetpub/wwwroot/(for details, see the attachment)
2. Modify the matweb. conf file in C:/inetpub/wwwroot/cgi-bin:
Add the following three lines:
[Test]
Mlserver = 10.10.19.162
Mldir = C:/inetpub/wwwroot/icons
3. Create two files test.mand test2.html under toolbox/webserver/wsdemos In the MATLAB installation directory (see the attachment)
OK. Test http: // 10.10.19.162/test1.html in the browser. Do you want to see the result!
**************************************** **************
Test. M content
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 Image Size Control ++ ++
% Modify the last two parameters in []
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 content
<! -- $ Revision: 1.2 $ -->
<HTML>
<Head>
<Title> Matlab Web server test </title>
</Head>
<Body bgcolor = "# ffffff">
<Br>
<Div align = "center"> <font color = "#000000" size = "4" face = "Arial">
<I> This is just a test file without aplications </I> </font> </div>
<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 content
<! -- $ Revision: 1.1 $ -->
<HTML>
<Body bgcolor = "# ffffff">
<Br>
<P align = "center">
</P>
</Body>
</Html>