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.
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).
Open the Permanent Magnet DC Motor example model by
the MATLAB® Command Window. This example model has data logging
for the whole model enabled.
Double-click the DC Motor subsystem to open it.
Simulate the model.
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.
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.
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.
Clear all the check marks and select the last variable
Then click anywhere on the model canvas to close the variable selection
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.
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.
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.