Symbolic Math Toolbox | ![]() ![]() |
Debugging
The maple
command provides two debugging facilities: trace mode and a status output argument.
Trace Mode
The command maple traceon
causes all subsequent Maple statements and results to be printed to the screen. For example,
maple traceon a = sym('a'); exp(2*a)prints all calls made to the Maple kernel for calculating
exp(2*a)
.
statement = (2)*(a); result = 2*a statement = exp(2*a); result = exp(2*a) ans = exp(2*a)To revert back to suppressed printing, use
maple traceoff
.
Status Output Argument
The maple
function optionally returns two output arguments, result
and status
. If the maple
call succeeds, Maple returns the result in the result
argument and zero in the status
argument. If the call fails, Maple returns an error code (a positive integer) in the status
argument and a corresponding warning/error message in the result
argument.
discrim
function calculates the discriminant of a polynomial and has the syntax discrim(p,x)
, where p
is a polynomial in x
. Suppose we forget to supply the second argument when calling the discrim
function
syms a b c x [result, status] = maple('discrim', a*x^2+b*x+c)Maple returns
result = Error, (in discrim) invalid arguments status = 2If we then include
x
[result, status] = maple('discrim', a*x^2+b*x+c, x)we get the following
result = -4*a*c+b^2 status = 0
![]() | Vectorized Example | Extended Symbolic Math Toolbox | ![]() |