This is machine translation

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

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

View Sparkline Plots of Simulation Data

This example shows the basic workflow for viewing sparkline plots of logged simulation data for selected blocks and variables directly on the model canvas. Before viewing sparkline plots, you must enable data logging for the whole model, or at least for those blocks where you want to display the data, and run the simulation.

Note

If you log Simscape™ data as part of the single simulation output, the sparkline plots functionality is not available. For more information, see Single simulation output (Simulink).

  1. Open the Permanent Magnet DC Motor example model by typing ssc_dcmotor in the MATLAB® Command Window. This example model has data logging for the whole model enabled.

  2. Double-click the DC Motor subsystem to open it.

  3. Simulate the model.

  4. To enable display of the sparkline plots on the model canvas, in the model window, from the top menu bar, select Display > Simscape > Toggle Sparklines When Clicked. This action adds the check mark next to the Toggle Sparklines When Clicked menu option, and you can start selecting blocks to display sparkline plots of logged data for their variables. Repeatedly selecting a block toggles the display of its sparkline plots on and off.

  5. Select the Rotational Electromechanical Converter block. Sparkline plots of the first three variables available for this block are displayed on the canvas, and the field below the plots shows that 5 more variables are available.

  6. To customize which plots are shown on the canvas, click the little wrench symbol in the field below the plots.

    This action displays a list of all the block variables available, with check marks next to the one currently plotted.

  7. Clear all the check marks and select the last variable w instead. Then click anywhere on the model canvas to close the variable selection box.

    As you hover over the field with the variable name on the canvas, it expands into a sparkline plot of logged simulation data for that variable.

    The plot display includes the minimum and maximum values, as well as time and value for the current cursor position.

  8. As you move your cursor past the right edge of the plot, the current value is replaced with the last value of the variable. Clicking or hovering over the arrow to the right of the sparkline plot opens an additional field underneath, which contains a link to the Simscape Results Explorer. When you click the icon, the Simscape Results Explorer window opens, displaying the corresponding plot in the right pane, with the appropriate node selected in the left pane.

Tips

  • If you select a block for which simulation data is not being logged, it displays No variables instead of the sparkline plots. Right-click the block, select Simscape > Log simulation data, and rerun the simulation.

  • To clear all plots and start again with a clean canvas, select Display > Simscape > Remove All Sparklines. Then you can select more blocks and variables to display their sparkline plots.

  • Repeatedly selecting the Toggle Sparklines When Clicked menu option toggles the ability to view the sparkline plots for the model on or off, as indicated by the check mark. When the check mark is on, repeatedly selecting a block toggles the display of its sparkline plots on and off.

Related Examples

More About