Installation guide

Creating MATLAB Web Server M-Files
2-7
Creating MATLAB Web Server M-Files
M-File Template
You use the M-file template to code your MATLAB application as you
normally do. The template provides the additional code you need to
accept input from your HTML input document and to return results to
your HTML output document. An abbreviated version looks like
function retstr = mfile_template(instruct, outfile)
% STEP 1
% Initialize the return string.
retstr = char('');
% STEP 2
% Set working directory.
% The variables INSTRUCT.MLDIR and INSTRUCT.MLID are
provided
% automatically to all MATLAB Web Server applications that
use
% the matweb program.
cd(instruct.mldir);
% STEP 3
% Get the HTML form input variables
my_input_variable_1 = instruct.my_input_variable_1;
% STEP 4
% Perform your MATLAB computations, graphics file creations,
% etc., here:
% STEP 5
% Put variables that you want to put into your HTML output
document in an output structure. You create an HTML output
document from OUTPUT_TEMPLATE.HTML.
outstruct.my_output_variable_1 = More MATLAB computations
creating ...
scalars, matrices, cell arrays, graphics files, etc.;
% STEP 6
% Call the function HTMLREP with the output structure you
just