This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Convert MuPAD Notebooks to MATLAB Live Scripts

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? (MATLAB) MuPAD notebooks are converted to live scripts by using Symbolic Math Toolbox™. For more information, see Getting Started with Symbolic Math Toolbox.

Convert a MuPAD Notebook .mn to a MATLAB Live Script .mlx

  1. 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.

  2. Convert the notebook: Use convertMuPADNotebook. For example, convert in the current folder to myScript.mlx in the same folder.


    Alternatively, right-click the notebook in the Current Folder browser and select Open as Live Script.

  3. 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.

  4. 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 technical support.

  5. 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.

  6. 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.

  7. 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.

Convert MuPAD Graphics to MATLAB Graphics

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, then export the graphic. See Save and Export Graphics.

Known Issues

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 technical support.

MuPAD Objects That Are Not Converted

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.

 Objects Not Converted

No Automatic Substitution in MATLAB

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

 Fixing This Issue

last(1) in MuPAD Is Not ans in MATLAB

In 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.

 Fixing This Issue

Some solve Results Are Wrongly Accessed

When 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.

 Fixing This Issue

break Inside case Is Wrongly Translated

In 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.

 Fixing This Issue

Some MuPAD Graphics Options Are Not Translated

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

 Fixing This Issue

Some Operations on Matrices Are Wrongly 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).

 Fixing This Issue

indets Behavior in MATLAB Differs

indets is translated to MATLAB symvar. However, symvar does not find bound variables or constant identifiers like PI.

Return Type of factor Differs in MATLAB

The return type of MuPAD factor has no equivalent in MATLAB. Subsequent operations on the results of factor in MATLAB might return incorrect results.

 Fixing This Issue

Layout Issues

  • 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 converted

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

Syntax Differences Between MATLAB and MuPAD

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