Plot a Circle Using the XY Graph Block
This example shows how to plot data using the XY Graph block. The XY Graph block is an alternative configuration of the Record block that plots two input signals on an XY plot. The XY plot used by the Record block is also available in the Simulation Data Inspector. The XY Graph block has all the capabilities of the Record block, including the ability to log data to the workspace and a file.
The model computes and
data to plot a circle using a third variable,
. Using a polar coordinate system, you can express the equation for a circle of radius
centered on the origin as:
Converting the equation to use Cartesian coordinates results in these equations for the and
data:
The model computes the data and the
data using Trigonometric Function blocks. The Ramp block provides the input,
, and the Constant block sets the radius of the circle.
To view the plotted results, simulate the model, then double-click the XY Graph block.
You can add subplots to the layout in the XY Graph block to view the data and the
data variations against time. For example, select Layouts. Then, under Overlays, select Bottom. Click Show Signals to view the signals. To plot the
x
signal, select the left overlay, then select the check box next to the x
signal. Then, to plot the y
signal, select the right overlay, then select the y
signal.
You can also update the styling of the data plotted on the XY plot. For example, remove the connecting line and add data markers. To add markers to the plot, on the Format tab, under Markers, click Markers. To remove the line from the plot, on the Format tab, under Line, click Line.
The XY plot supports other analysis and visualization features including trend lines and the ability to plot more than one series. For more information, see Visualize Simulation Data on an XY Plot and Analyze Data Using the XY Plot.