Products & Services Solutions Academia Support User Community Company

Learn more about Symbolic Math Toolbox   

Understanding MuPAD

Introduction to MuPAD

Version 5 of Symbolic Math Toolbox is powered by the MuPAD symbolic engine.

The MATLAB Workspace and MuPAD Engines

A MuPAD engine is a separate process that runs on your computer in addition to a MATLAB process. A MuPAD engine starts when you first call a function that needs a symbolic engine, such as syms. Symbolic Math Toolbox functions that use the symbolic engine use standard MATLAB syntax, such as y = int(x^2).

Conceptually, each MuPAD notebook has its own symbolic engine, with associated workspace. You can have any number of MuPAD notebooks open simultaneously.

The engine workspace associated with the MATLAB workspace is generally empty, except for assumptions you make about variables. For more information, see Clearing Assumptions and Resetting the Symbolic Engine.

Introductory Example Using a MuPAD Notebook from MATLAB

This example shows how to use a MuPAD notebook to calculate symbolically the mean and variance of a normal random variable that is restricted to be positive. For more information on using a MuPAD notebook, see Calculating in a MuPAD Notebook.

The density function of the normal and positive random variable is

  1. At the MATLAB command line, enter the command

    mupad
  2. A blank MuPAD notebook opens. You perform calculations by typing in the input area, demarcated by a left bracket.

  3. In the input area, type

    f := exp(-x^2/2)*sqrt(2/PI)

    and press Enter.

      Note   Assignment in a MuPAD notebook uses :=, not the MATLAB syntax =. Also, the MuPAD syntax for the mathematical constant π is PI, not the MATLAB syntax pi. For more information on common syntax differences, see Differences Between MATLAB and MuPAD Syntax.

    The MuPAD notebook displays results in real math notation.

    Your notebook appears as follows.

  4. The mean of the random variable is

    To calculate the mean of the random variable, type

    mean := 
    1. To place an integral in the correct syntax, click the integral button in the right-hand command bar, and select definite limits as shown.

    2. The correct syntax for integration appears in the input area.

    3. Replace #f with x*f, #x with x, #a with 0, and #b with infinity.

      • Use the Tab key to select the replaceable fields #f, #x, etc.

      • Use Ctrl+space to autocomplete inputs; e.g., enter infi followed by Ctrl+space to enter infinity.

    Once your input area reads

    mean := int(x*f, x=0..infinity)

    press Enter.

      Note   The syntax for integration, and for infinity, differ from the MATLAB versions.

  5. The variance of the random variable is

    To calculate the variance of the random variable, type

    variance := int((x-mean)^2*f, x=0..infinity)

    and press Enter.

  6. The result of evaluating variance is a complicated expression. Try to simplify it with the simplify command. Type

    simplify(variance)

    and press Enter. The result is indeed simpler.

  7. Another expression for the variance of the random variable is

    To calculate the variance of the random variable using this definition, type

    variance2 := int(x^2*f, x=0..infinity) - mean^2

    and press Enter.

    The two expressions for variance, variance and variance2, are obviously equivalent.

For more information on working in MuPAD notebooks, select Help > Open Help, or press F1 to launch the MuPAD Help viewer.

Within the MuPAD Help viewer, both the "Getting Started" and "The MuPAD Notebook Interface" sections can help you understand and use MuPAD notebooks.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS