Evaluate Mathematical Expressions and Commands

MuPAD® notebooks will be removed in a future release. 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.

Working in a Single Input Region

To evaluate an expression or execute a command in a notebook, press Enter:

3*2^10 + 1/3 - 3

The results appear in the same grey bracket below the input data. By default, the commands and calculations you type appear in red color, the results appear in blue.

To suppress the output of a command, terminate a command with a colon. This allows you to hide irrelevant intermediate results. For example, assign the factorial of 123 to the variable a, and the factorial of 132 to the variable b. In MuPAD®, the assignment operator is := (the equivalent function is _assign). The factorial operator is ! (the equivalent function is fact). Terminate these assignments with colons to suppress the outputs. Here MuPAD displays only the result of the division a/b:

a := 123!: b := 132!: a/b

delete a, b:

You can enter several commands in an input region separating them by semicolons or colons:

a+b; a*b; a^b

To start a new line in an input region, press Ctrl+Enter or Shift+Enter.

Working with Multiple Input Regions

If you have several input regions, you can go back to previous calculations and edit and reevaluate them. If you have a sequence of calculations in several input regions, the changes in one region do not automatically propagate throughout other regions. For example, suppose you have the following calculation sequence:

y := exp(2*x)

z := x + y

If you change the value of the variable y, the change does not automatically apply to the variable z. To propagate the change throughout different input regions, select Notebook from the main menu. From here you can:

  • Select Evaluate to evaluate calculations in one input region.

  • Select Evaluate From Beginning to evaluate calculations in the input regions from the beginning of a notebook to the cursor position.

  • Select Evaluate To End to evaluate calculations in the input regions from the cursor position to the end of a notebook.

  • Select Evaluate All to evaluate calculations in all input regions in a notebook.

Also, you can propagate the change throughout multiple input regions by pressing Enter in each input region.