Main Content

Analyze Data Using the XY Visualization

In the Simulation Data Inspector, you can plot time series data on an XY visualization to analyze relationships between signals. This example demonstrates how to view and analyze data on an XY visualization using trend lines and example data. The example data file attached includes more data than the example covers. You can apply the steps covered in the following sections to each set of signals to use each trend line option.

Import and Plot Data on the XY Visualization

The data for this example is stored in a MAT-file. You can import the data through the UI, or you can use the Simulink.sdi.createRun function. Then, open the Simulation Data Inspector to view the data.

xyRunID = Simulink.sdi.createRun('XY signals','file','ex_xy_data.mat');
Simulink.sdi.view

To plot the data on an XY visualization, you need to add the visualization to the layout. By default, the Simulation Data Inspector uses Time Plot visualizations for each subplot in the layout.

To add an XY visualization to your layout, open the Visualization Gallery by selecting Edit View from the Layouts menu.

From the Visualization Gallery, drag and drop the XY icon onto the plot.

To plot signals on the XY visualization, select two signals and drag them onto the plot. For example, drag and drop the Heart-X and Heart-Y signals onto the plot. Specify which signal to use as x-data and which to use as y-data in the dialog that appears in the lower-right of the plot.

You can customize the appearance of the XY visualization using the XY Settings. The line and marker colors can match the color for the signal providing the x data or for the signal that provides the y data. By default, the line and markers use the y-Axis signal color. Specified settings apply for all XY visualizations in your layout.

Analyze XY Data Using a Trend Line

You can add a trend line to an XY visualization to analyze the relationship between the x- and y-data. The trend line is most useful when the relationship can be expressed as a function. The Heart-X and Heart-Y data plotted in the prior section is not well-suited for trend line analysis because the y-data is not well correlated with the x-data. Trend line analysis works well when the relationships between the x and y data can be expressed as a function.

The example data includes x- and y-data well-suited for each available type of trend line. You can try plotting each pair of signals to see how each trend line helps you analyze the data. For example, plot the Poly-X and Poly-Y signals on the XY visualization:

  1. Select both signals.

  2. Drag and drop the signals onto the plot.

  3. Select Poly-X for x-Axis and Poly-Y for y-Axis in the drop-down menus on the dialog. You can only plot one pair of signals on the XY visualization.

  4. Click OK.

To add a trend line, open the XY Settings and select Show trend line. The default trend line type is Linear. Select Polynomial from the Type drop-down.

By default, the Simulation Data Inspector computes the trend line in the form of a third-order polynomial. You can use the text box next to the selected Type to specify the order of the polynomial, between 2 and 6. Modify the order of the trend line polynomial to see how it affects the fit of the trend line. For example, when you change to use a second-order polynomial, the trend line does not fit the start of the data as well.

Try out other trend line options to see how they fit the Poly-X and Poly-Y data. You can add these types of trend line to the XY visualization:

  • Linear: The trend line equation is of the form y=mx+b.

  • Logarithmic: The trend line equation is of the form y=aln(x)+b. The x-data must not contain 0 or negative values.

  • Polynomial: The trend line equation is of the form y=b6x6...+b2x2+b1x+a, where the number of terms is determined by the specified order.

  • Exponential: The trend line equation is of the form y=aebx. The y-data must not contain 0 or negative values.

  • Power: The trend line equation is of the form y=axb. The x- and y-data must not contain 0 or negative values.

Try plotting other pairs of signals in the XY visualization and explore how each trend line option fits each data set.