MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.
MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.
To access built-in MuPAD functions at the MATLAB command
These functions are designed to work like the existing MATLAB
not open a MuPAD notebook, and therefore, you cannot use these
functions to access MuPAD graphics capabilities.
evalin, the syntax is
y = evalin(symengine,'MuPAD_Expression');
evalin when you want to perform computations
in the MuPAD language, while working in the MATLAB workspace.
For example, to make a three-element symbolic vector of the
= 1 to
y = evalin(symengine,'[sin(k*x) $ k = 1..3]')
y = [ sin(x), sin(2*x), sin(3*x)]
For evaluating a MuPAD function, you can also use the
a different syntax than
evalin, so it can be
simpler to use. The syntax is:
y = feval(symengine,'MuPAD_Function',x1,...,xn);
MuPAD_Function represents the name
of a MuPAD function. The arguments
be symbolic variables, numbers, or character vectors. For example,
to find the tenth element in the Fibonacci sequence, enter:
z = feval(symengine,'numlib::fibonacci',10)
z = 55
The next example compares the use of a symbolic solution of
an equation to the solution returned by the MuPAD numeric
near the point
x = 3.
The symbolic solver returns these results:
syms x f = sin(x^2); solve(f)
ans = 0
The numeric solver
fsolve returns this
ans = x == 3.0699801238394654654386548746678
As you might expect, the answer is the numerical value of . The setting of MATLAB
not affect the display; it is the full returned value from the MuPAD
evalin(symengine,...) function causes
the MuPAD engine to evaluate a character vector. Since the MuPAD engine
workspace is generally empty, expressions returned by
not simplified or evaluated according to their definitions in the MATLAB workspace.
syms x y = x^2; evalin(symengine, 'cos(y)')
ans = cos(y)
y is not expressed in terms of
unknown to the MuPAD engine.
feval(symengine,...) can pass
symbolic variables that exist in the MATLAB workspace, and these
variables are evaluated before being processed in the MuPAD engine.
syms x y = x^2; feval(symengine,'cos',y)
ans = cos(x^2)
By default, MuPAD performs all computations in an exact
form. When you call the
with floating-point numbers as arguments, the toolbox converts these
arguments to rational numbers before passing them to MuPAD. For
example, when you calculate the incomplete gamma function, the result
is the following symbolic expression:
y = feval(symengine,'igamma', 0.1, 2.5)
y = igamma(1/10, 5/2)
To approximate the result numerically with double precision,
format long double(y)
ans = 0.028005841168289
Alternatively, use quotes to prevent the conversion of floating-point arguments to rational numbers. (The toolbox treats arguments enclosed in quotes as character vectors.) When MuPAD performs arithmetic operations on numbers involving at least one floating-point number, it automatically switches to numeric computations and returns a floating-point result:
feval(symengine,'igamma', '0.1', 2.5)
ans = 0.028005841168289177028337498391181
For further computations, set the format for displaying outputs