feval

Evaluate MuPAD expressions specifying their arguments

Syntax

result = feval(symengine,F,x1,...,xn)
[result,status] = feval(symengine,F,x1,...,xn)

Description

result = feval(symengine,F,x1,...,xn) evaluates F, which is either a MuPAD® function name or a symbolic object, with arguments x1,...,xn, with result a symbolic object. If F with the arguments x1,...,xn throws an error in MuPAD, then this syntax throws an error in MATLAB®.

[result,status] = feval(symengine,F,x1,...,xn) lets you catch errors thrown by MuPAD. This syntax returns the error status in status, and the error message in result if status is nonzero. If status is 0, result is a symbolic object. Otherwise, result is a string.

Input Arguments

F

MuPAD function name or symbolic object.

x1,...,xn

Arguments of F.

Output Arguments

result

Symbolic object or string containing a MuPAD error message.

status

Integer indicating the error status. If F with the arguments x1,...,xn executes without errors, the error status is 0.

Examples

syms a b c x
p = a*x^2+b*x+c;
feval(symengine,'polylib::discrim', p, x)
ans =
b^2 - 4*a*c

Alternatively, the same calculation based on variables not defined in the MATLAB workspace is:

feval(symengine,'polylib::discrim', 'a*x^2 + b*x + c', 'x')
ans =
b^2 - 4*a*c

Try using polylib::discrim to compute the discriminant of the following nonpolynomial expression:

[result, status] = feval(symengine,'polylib::discrim',...
                                   'a*x^2 + b*x + c*ln(x)', 'x')
result =
Error: An arithmetical expression is expected. [normal]

status =
     2

Alternatives

evalin lets you evaluate MuPAD expressions without explicitly specifying their arguments.

More About

expand all

Tips

  • Results returned by feval can differ from the results that you get using a MuPAD notebook directly. The reason is that feval sets a lower level of evaluation to achieve better performance.

  • feval does not open a MuPAD notebook, and therefore, you cannot use this function to access MuPAD graphics capabilities.

Was this topic helpful?