# Documentation

### This is machine translation

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

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

## Use Graphics

MuPAD® notebooks are not recommended. 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.

### Graphic Options Available in MuPAD

#### Basic Plotting Options

MuPAD® presents many options for creating and working with graphics and animations. The simplest way to create a plot in MuPAD is to use the `plot` command. Using this command, you can:

You can format the plot interactively.

#### Advanced Plotting Options

The `plot` command provides a basic way to create function plots. For example, you can:

To see all functions available in the MuPAD graphics library, enter:

`info(plot)`

### Basic Plotting

#### Create 2-D Plots

The simple way to create a 2-D plot of a function is to use the `plot` command:

`plot(sin(x)*cos(3*x))`

#### Create 3-D Plots

The simple way to create a 3-D plot of a function is to use the `plot` command with the option `#3D`:

`plot(sin(x)*sin(y), #3D)`

### Note

By default, for a function of two variables, the `plot` command creates a 2-D animation. Using the option `#3D` lets you create a 3-D plot instead of a 2-D animation.

#### Plot Multiple Functions in One Graph

To plot several functions in one figure, list all the functions, separating them by commas. MuPAD uses different colors when plotting multiple functions:

`plot(sin(x), cos(x), tan(x), cot(x))`

You can use the sequence generator `\$` to create a sequence of functions:

`plot(sin(k*x) \$ k = 1..3)`

You also can plot multiple functions in one 3-D graph:

`plot(-sqrt(r^2 - x^2 - y^2) \$ r = 1..5, #3D)`

#### Specify Plot Ranges

You can specify a range over which to plot a function:

`plot(sin(x^3)*exp(x), x = 3..5)`

`plot(sin(x)*sin(y), x = 0..3, y = 1..3, #3D)`

For multiple functions plotted in one graph, you can specify one range for all the functions:

`plot(sin(k*x) \$ k = 1..5, x = 0..2*PI)`

To specify different ranges for multiple functions plotted in one graph, use different variables:

`plot({sin(k*x), k*t^2} \$ k = 1..5, x = 0..2*PI, t = -1..1)`

#### Plot Piecewise Functions

To specify a piecewise function, use the `piecewise` command. You can plot a piecewise function even if it is undefined at some points. for example, you can plot the following function although the function is not defined for `-2 < x < -1`:

```plot(piecewise([x < - 2, - 1], [-1 < x and x < 0, x^2], [0 < x and x < 1, -x^2], [x > 1, 1]))```

### Format Plots

#### Enable Plot Formatting Mode

In MuPAD, you can format your graphic results interactively when working in plot formatting mode. To switch to graphics formatting mode, click any place on a plot. In this mode, the Object Browser pane appears.

If you do not see the Object Browser and Property panes, select View > Object Browser or click on the toolbar.

The top of the Object Browser pane displays the components of your graphics such as scene (background), coordinate system, and a function plot. For further information on the structure of graphics, see The Full Picture: Graphical Trees.

After you select a component in the Object Browser pane, the bottom of the pane displays the properties of this component.

#### Change Background Settings

To change background settings of your graphics, switch to plot formatting mode and select Scene at the top of the Object Browser pane. The bottom of the pane shows background properties that you can change. For example, you can change the background color. To choose the color, select BackgroundColor and click the ellipsis button.

You can use predefined colors or select a color from a more extensive palette.

#### Modify Axes

To format the axes of your graphics, switch to plot formatting mode and select Coordinate System at the top of the Object Browser pane. The bottom of the pane shows axes properties that you can change. For example, you can add grid lines.

#### Modify Function Plot

To format the function plot, switch to plot formatting mode and select Function at the top of the Object Browser pane. The bottom of the pane shows plot properties that you can change. For example, you can change the color of a function plot.

You can use predefined colors or select a color from a more extensive palette.

### Present Graphics

When you present graphic results in MuPAD, you can move, zoom, and rotate your graphics. You also can select different components of a plot. When presenting graphic results, switch to the plot formatting mode. You can use the following toolbar to manually rotate, move, zoom your plot, and show coordinates of any point on your plot:

To see the coordinates for a point on your plot, click the point and hold the mouse button. You can move the cursor while holding the mouse button and see the coordinates of all the points on the path of the cursor.

You can use the toolbar to rotate and zoom your plot automatically. You also can change the speed for rotation and zooming.

### Create Animated Graphics

#### Creating Animated 2-D Plots

To create an animated plot, use an additional changing parameter for the function you want to plot. Specify the range for this parameter. The following example presents an animated plot of a function with the parameter `a` that gradually changes value from 2 to 6:

`plot(exp(x)*sin(a^2*x), x = 1..2, a = 2..6)`

#### Create Animated 3-D Plots

To create an animated 3-D plot, use an additional changing parameter for the function you want to plot. Specify the range for this parameter and the option `#3D`. The following example presents an animated plot of a function with the parameter `a` that gradually changes value from 0.1 to 2:

`plot(sin(a*x^2 + a*y^2), x = -2..2, y = -2..2, a = 0.1..2, #3D)`

#### Play Animations

MuPAD displays the first frame of an animation as static picture. To play the animation, click the picture.

When MuPAD plays an animation, the Animation toolbar with the player controls appears:

#### Count Backwards

To play an animation forward and then backward, click the Repetition button and select the option Back and Forth.

You also can specify the range for a parameter so that the initial value is greater than the final value. The following example creates an animated plot of the function using the parameter `a` that gradually changes value from 2 to 0.1:

`plot(sin(a*x^2 + a*y^2), x = -2..2, y = -2..2, a = 2..0.1, #3D)`