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.
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
Double-click the DC Motor subsystem to open it.
Simulate the model.
To enable display of the sparkline plots on the model canvas, select any Simscape block in the model, for example, the Rotational Electromechanical Converter block. On the Simscape Block tab at the top of the model window, under Review Results, click Sparkline Plot > Enable Sparkline Plots. This action adds the check mark next to the Enable Sparkline Plots option, and you can start selecting blocks to display sparkline plots of logged data for their variables. Repeatedly clicking a block toggles the display of its sparkline plots on and off.
Click the Rotational Electromechanical Converter block again, to toggle its sparkline plots on. 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 wheel 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 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.
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, on the Simscape Block tab, click Sparkline Plot > Remove Sparklines. Then you can select more blocks and variables to display their sparkline plots.
Repeatedly selecting the Enable Sparkline Plots 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 clicking a block toggles the display of its sparkline plots on and off.