MATLAB Web Server Previous page   Next Page

MATLAB Graphics

The webpeaks function, included as a demonstration program, creates a peaks plot and returns the output to your Web browser. In examining portions of the webpeaks code, you will see how to include MATLAB graphics as part of a MATLAB Web Server application.

To start the webpeaks demonstration, set the URL in your browser to
http://<your_domain>/webpeaks1.html, the webpeaks input document.

This input document allows you to set the characteristics of the peaks plot you want to generate. This is a more complex input document than the one we used with webmagic, as it makes use of HTML frames. The code in the source file

calls the webpeaks function and targets the output to a frame on the lower portion of the input document itself.

In addition to the code necessary to compute and display the peaks function, the file webpeaks.m contains additional code specific to the transmission of graphics data across the Web. In webpeaks.m the code

extracts mlid from the structure h.

mlid is a unique identifier that matlabserver provides. Using the value of mlid to construct filenames ensures that filenames are unique. It can also be used to maintain contexts among the different connections in an application.You can see this in the code

which creates a name for a jpeg file. If mlid has the value ml00277, for example, the jpeg file will be named ml00277peaks.jpeg.

The function htmlrep replaces MATLAB variable names it finds in the HTML output template file webpeaks2.html with the values in the input structure s.

$GraphFileName$, the variable that represents the graphic output, is found in the line

in webpeaks2.html.

The final output document shows both the input and output frames.


Previous page  Additional Application Examples Stock Price Simulation Next page