This example shows how you can set your model to log simulation data for selected blocks only and how to view simulation data using Simscape™ Results Explorer.
Open the Permanent Magnet DC Motor example model by typing
ssc_dcmotor in the MATLAB® Command Window. Double-click the DC Motor subsystem to open it.
Open the Configuration Parameters dialog box and then, in the left pane, select
Simscape. This example model has data logging for the whole model
enabled. To enable data logging on a block-by-block basis, set the Log
simulation data parameter to
Use local settings
and click OK.
Select the blocks for data logging. Right-click the Rotational Electromechanical Converter block. From the context menu, select Simscape > Log simulation data .
After you select a block for data logging, a check mark appears in front of the Log simulation data option in the context menu for that block.
Right-click the Inertia block and select it for data logging, as described in the previous step.
Simulate the model. This creates a workspace variable named
simlog_ssc_dcmotor (as specified by the Workspace variable
name parameter), which contains the simulation data for selected blocks
To open the Simscape Results Explorer, right-click one of the blocks previously selected for data logging, for example, the Rotational Electromechanical Converter block. From the context menu, select Simscape > View simulation data > simlog_ssc_dcmotor.
If you right-click a block that has not been selected for simulation data logging, for example, the Load Torque block, the View simulation data option is not available.
If you change the name of the log variable between simulation runs, the context menu
lists the names of all the log variables associated with the block. For example, to
compare data from two simulation runs, you can use different variable names (such as
simlog2). Open a Simscape Results Explorer window with
simlog1 results, then
unlink it from the session and open another window with
results. For more information, see About the Simscape Results Explorer.
The Simscape Results Explorer window opens, with the
Rotational_Electromechanical_Converter node already selected in the
left pane, and all the node plots for this block displayed in the right pane. You can see
that it contains simulation data only for the two selected blocks, Rotational
Electromechanical Converter and Inertia.