Differences Between MATLAB and MuPAD Syntax

Note

To convert a MuPAD notebook file to a MATLAB live script file, see convertMuPADNotebook. MATLAB live scripts support most MuPAD functionality, although there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

There are several differences between MATLAB and MuPAD syntax. Be aware of which interface you are using in order to use the correct syntax:

• Use MATLAB syntax in the MATLAB workspace, except for the functions evalin(symengine,...) and feval(symengine,...), which use MuPAD syntax.

You must define MATLAB variables before using them. However, every expression entered in a MuPAD notebook is assumed to be a combination of symbolic variables unless otherwise defined. This means that you must be especially careful when working in MuPAD notebooks, since fewer of your typos cause syntax errors.

This table lists common tasks, meaning commands or functions, and how they differ in MATLAB and MuPAD syntax.

Assignment:==
List variablesanames(All, User)whos
Numerical value of expressionfloat(expression)double(expression)
Suppress output:;
Enter matrixmatrix([[x11,x12,x13], [x21,x22,x23]])[x11,x12,x13; x21,x22,x23]
Auto-completionCtrl+space barTab
Equality, inequality comparison=, <>==, ~=

The next table lists differences between MATLAB expressions and MuPAD expressions.

infinityInf
PIpi
Ii
undefinedNaN
truncfix
arcsin, arccos etc.asin, acos etc.
numeric::intvpaintegral
normalsimplifyFraction
besselJ, besselY, besselI, besselKbesselj, bessely, besseli, besselk
lambertWlambertw
Si, Cisinint, cosint
EULEReulergamma
conjugateconj
CATALANcatalan
TRUE, FALSEsymtrue, symfalse

The MuPAD definition of exponential integral differs from the Symbolic Math Toolbox™ counterpart.

Exponential integral

Symbolic Math Toolbox provides two functions to calculate exponential integrals: expint(x) and ei(x). The definitions of these two functions are described below.

$\text{expint}\left(x\right)=\underset{x}{\overset{\infty }{\int }}\frac{{e}^{-t}}{t}\text{ }dt\text{.}$

$\text{ei}\left(x\right)=\underset{-\text{ }\infty }{\overset{x}{\int }}\frac{{e}^{t}}{t}\text{\hspace{0.17em}}dt.$

$\text{Ei}\left(x\right)=\underset{-\infty }{\overset{x}{\int }}\frac{{e}^{t}}{t}\text{ }dt.$

$\text{Ei}\left(n,x\right)=\underset{1}{\overset{\infty }{\int }}\frac{{e}^{-xt}}{{t}^{n}}\text{ }dt.$

The definitions of Ei extend to the complex plane, with a branch cut along the negative real axis.

Symbolic Math Toolbox Documentation

Mathematical Modeling with Symbolic Math Toolbox

Get examples and videos