Main Content

Migrate MuPAD^{®} notebooks to MATLAB^{®} live scripts that use MATLAB code. Live scripts are an interactive way to run MATLAB code. For details, see What Is a Live Script or Function?. MuPAD notebooks are converted to live scripts by using Symbolic Math Toolbox™. For more information, see Get Started with Symbolic Math Toolbox.

`.mn`

to a MATLAB Live Script `.mlx`

**Prepare the notebook:**This step is optional, but helps avoid conversion errors and warnings. Check if your notebook contains untranslatable objects from MuPAD Objects That Are Not Converted. These objects cause translation errors or warnings.**Convert the notebook:**Use`convertMuPADNotebook`

. For example, convert`myNotebook.mn`

in the current folder to`myScript.mlx`

in the same folder.convertMuPADNotebook('myNotebook.mn','myScript.mlx')

Alternatively, right-click the notebook in the Current Folder browser and select

**Open as Live Script**.**Check for errors or warnings:**Check the output of`convertMuPADNotebook`

for errors or warnings. If there are none, go to step 7. For example, this output means that the converted live script`myScript.mlx`

has`4`

errors and`1`

warning.Created ''myScript.mlx': 4 translation errors, 1 warnings. For verifying... the document, see help.

A translation error means that the translated code will not run correctly while a translation warning indicates that the code requires inspection. If the code only contains warnings, it will likely run without issues.

**Fix translation errors**: Open the converted live script by clicking the link in the output. Find errors by searching for`ERROR`

. The error explains which MuPAD command did not translate correctly. For details and fixes, click`ERROR`

. After fixing the error, delete the error message. For the list of translation errors, see Troubleshoot MuPAD to MATLAB Translation Errors. If you cannot fix your error, and the Known Issues do not help, please contact MathWorks Technical Support.**Fix translation warnings:**Find warnings by searching for`WARNING`

. The warning text explains the issue. For details and fixes, click`WARNING`

. Decide to either adapt the code or ignore the warning. Then delete the warning message. For the list of translation warnings, see Troubleshoot MuPAD to MATLAB Translation Warnings.**Verify the live script:**Open the live script and check for unexpected commands, comments, formatting, and so on. For readability, the converted code may require manual cleanup, such as eliminating auxiliary variables.**Execute the live script:**Ensure that the code runs properly and returns expected results. If the results are not expected, check your MuPAD code for the Known Issues listed below.

To convert MuPAD graphics, first try to convert the MuPAD plot commands that generated the graphics. This approach ensures you can control the graphical output in MATLAB similar to MuPAD. If you cannot convert the MuPAD commands that produce graphics, then you can export the graphics into vector or bitmap formats.

These are the known issues when converting MuPAD notebooks to MATLAB live scripts with the `convertMuPADNotebook`

function. If your issue is not described, please contact
MathWorks Technical
Support.

Expand the list to view MuPAD objects that are not converted. To avoid conversion errors and warnings, remove these objects or commands from your notebook before conversion.

In MATLAB, when symbolic variables are assigned values, then expressions containing those values are not automatically updated.

`last(1)`

in MuPAD Is Not `ans`

in MATLABIn MuPAD, `last(1)`

always returns the
last result. In MATLAB, `ans`

returns the result
of the last *unassigned* command. For example,
in MATLAB if you run `x = 1`

, then calling `ans`

does
not return `1`

.

`solve`

Results Are Wrongly AccessedWhen results of MuPAD `solve`

are accessed, `convertMuPADNotebook`

assumes
that the result is a finite set. However, if the result is a non-finite
set then the code is wrongly translated.

`break`

Inside `case`

Is Wrongly TranslatedIn MuPAD, a `break`

ends a case in a switch
case. However, MATLAB does not require a `break`

to
end a case. Thus, a MuPAD `break`

introduces
an unnecessary `break`

in MATLAB. Also, if a MuPAD case
omits a `break`

, then the MATLAB case will not
fall-through.

While the most commonly used MuPAD graphics options are translated, there are some options that are not translated.

Operations on matrices are not always translated correctly.
For example, if `M`

is a matrix, then `exp(M)`

in MuPAD is
wrongly translated to `exp(M)`

instead of the matrix
exponential `expm(M)`

.

`indets`

Behavior in MATLAB Differs`indets`

is translated to MATLAB
`symvar`

. However, `symvar`

does not find bound variables or constant identifiers like `PI`

in
MuPAD.

`factor`

Differs in MATLABThe return type of MuPAD `factor`

has
no equivalent in MATLAB. Subsequent operations on the results
of `factor`

in MATLAB might return incorrect
results.

MuPAD notebook frames are not converted.

MuPAD notebook tables are not converted.

MuPAD plots are not interactive in live scripts.

Titles or headings in MuPAD notebooks are not always detected.

MuPAD text attribute

`underline`

is not convertedText formatting: Font, font size, and color are not converted. All text in live scripts looks the same.

For the syntax differences between MATLAB and MuPAD, see Differences Between MATLAB and MuPAD Syntax.