Installation guide
Debugging Your Application
2-13
Debugging Your Application
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
retstr = webmagic(structure, testfile)
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.
retstr = htmlrep(outstruct,'webmagic2.html', outfile)