Using the Simulink Debugger (Example 2)
02 Feb 2004
(Updated 23 Jun 2010)
Explores using the Simulink Debugger to extract information.
% This MATLAB script file will show the following:
% # Leverage the Simulink Debugger to interrogate information on simulation
% execution in a batched manner (usually done interactively).
% # Use Simulink Debugger to specifically access failed step information
% when using variable step solvers, specifically identifying the
% limiting state causing the failure.
% # Parse Debugger information to replace with Simulink's state
% definition or user defined state definition.
% ADVICE: Did you know you can use the MATLAB debugger to step through
% this file line by line! WOW!
% Copyright 2004 - 2010 The MathWorks, Inc.
%% Clean up current session
% check if a solvertrace.txt file exists, deleting so as not to append
%% lets look at the VDP model
% The following model is a modified VDP model with the accelerator turned on.
% Look inside the GETTRACE command for more information on this decision.
out = parsestrace('solvertrace.txt')
% Look at all the useful information that the Simulink Debugger can get
% you! Reference the Simulink Debugger Command reference in the
% Refer to the great Simulink Debugger Section in the documentation!
% web([docroot '/toolbox/simulink/ug/debug.html'])
% EXERCISE 1:
% Can you use the debugger to find out how hard Simulink is working to
% solve the Algebraic Loop in the HYDCYL Simulink model!! Can you also
% have the Simulink Debugger highlight all the blocks that constitute the
% algebraic loop!
% - do this interactively through the GUI and MATLAB command line
% - see Simulink Debugger command ATRACE!
% - see Simulink Debugger command ASHOW!
% EXERCISE 2:
% Can you use the Simulink Debugger to see the block execution order of the
% ONECART Simulink model!
% - do this interactively through the GUI and the MATLAB command line
% - in the Simulink Debugger GUI see the Sorted List Tab
% - or use the SLIST command
% EXERCISE 3:
% Can you write your own batched Simulink Debugger run that writes out to a
% file the complete sorted lists of model AERO_DAP3DOF!
% - Copy GETSTRACE to your own GETSLIST and begin modifying it.
% - use command SLIST within the batched Debugger commands.
% - You do not need to run the simulation! Only bring up the debugger
% run the SLIST command, and get out of the debugger.