MATLAB Web Server | ![]() ![]() |
Debugging Procedure
You can use the MATLAB debugging facility plus your Web browser to debug your application before making it available to all users.
An effective method of debugging is to write your application M-file to accept two arguments, as in
You can use the second argument to create an HTML file that displays test output.
As a first debugging step, create a driver program that sets up the input variables and calls the main function. You can use the MATLAB debugging facilities to check the logic of your test program. The file twebmagic.m
located in <matlab>/toolbox/webserver/wsdemos
is an example of such a driver program. (Note the use of the wssetfield
function to create the test input variables. This is optional. Elements of the structure s
could be created directly, e.g., s.msize =
'5'.)
function twebmagic() %TWEBMAGIC Example standalone test of webmagic function. %TWEBMAGIC Does setup and calls webmagic. Creates the output file, %twebmagic.html. % Set up input variables. s = {}; s = wssetfield(s, 'mlmfile', 'webmagic'); s = wssetfield(s, 'msize', '5'); s = wssetfield(s, 'mldir', '.'); % Create an output test file. str = webmagic(s, 'twebmagic.html');
Because the driver program calls webmagic
with two arguments, webmagic
writes its output to the file twebmagic.html. The call to htmlrep within the webmagic function handles this.
outfile in this case is twebmagic.html, the second argument passed to webmagic
.
The second step in debugging is to use your Web browser to examine your test file (outfile)and make appropriate changes until the output is displayed as you intend.
Debugging Template
To assist you in debugging, we have provided the template tmfile_template.m
, shown below in abbreviated form.
function tmfile_template() % STEP 1 % Set up input variables as they would come in from % the HTML input form created from INPUT_TEMPLATE.HTML. outstruct.my_input_variable_1 = some appropriate test value; % STEP 2 % Call your application function that was created from % <MFILE_TEMPLATE.M>. Replace <MFILE_TEMPLATE> with the % name of your application M-file. Provide a test output % file name for the optional argument by replacing % <TEST_OUTPUT.HTML> with your test output HTML file name. retstr = <MFILE_TEMPLATE>(outstruct, '<TEST_OUTPUT.HTML>'); % STEP 3 % Examine the file you supplied for <TEST_OUTPUT.HTML> in % your web browser.
![]() | Creating Output Documents | Additional Application Examples | ![]() |