|On this page…|
You can configure the same properties for logging states and local data in a chart as you can for logging signals in a model:
|Log signal data (for data) or Log self data (for states)||Saves the signal or state's value to the MATLAB workspace during simulation.|
|Logging name||Name of the logged signal. Defaults to the original name of the state or local data. To rename the logged signal, select Custom and enter a new name. For guidance on when to use a different name for a logged signal, see Specify Signal-Level Logging Name in the Simulink documentation.|
|Limit data points to last||Limits the amount of data logged to the most recent samples. See Limit Data Points to Last in the Simulink documentation.|
|Decimation value||Limits the amount of data logged by skipping samples. For example, a decimation factor of 2 saves every other sample. See Decimation in the Simulink documentation.|
Logging and Accessibility Options in the Simulink documentation
There are several ways to configure states and local data for logging:
|Method||When to Use|
|Log Individual States and Data||Configure states or local data for logging one at a time from inside the chart.|
|Log Multiple Signals At Once||Configure multiple signals for logging from a list of all states and local data.|
|Log Chart Signals Using the Command-Line API||Configure logging properties programmatically.|
The following procedure explains how to log individual states and data for any chart. For example, try the procedure with the sf_semantics_hotel_checkin model, which uses a chart to simulate a hotel check-in process. To open the model, click sf_semantics_hotel_checkinsf_semantics_hotel_checkin or type sf_semantics_hotel_checkin at the MATLAB® command prompt.
Open the properties dialog box for the state or local data.
|States||Right-click the state and select Properties.|
Right-click the state or transition that uses the local data and select Explore > (data) variable_name.
In the properties dialog box, click the Logging tab.
Modify properties as needed, as described in Properties to Configure for Logging.
Open the properties dialog box for the service local data and select the Log signal data check box.
Open the properties dialog box for the Dining_area state, select the Log self activity check box, and change the logging name to Dining_Room.
The following procedure explains how to log multiple signals at once for any chart. For example, try the procedure with the sf_semantics_hotel_checkin model, which uses a chart to simulate a hotel check-in process. To open the model, click sf_semantics_hotel_checkinsf_semantics_hotel_checkin or type sf_semantics_hotel_checkin at the MATLAB command prompt.
In the chart, select Simulation > Output > Log Chart Signals.
The Stateflow® Signal Logging dialog box opens, showing all states and local data. These chart objects are the signals you can log.
Select the check box next to each signal you want to log.
The Log signal data check box is selected automatically for each signal you log. For example, in the Hotel chart of the sf_semantics_hotel_checkinsf_semantics_hotel_checkin model, log the Check_in.Checked_in.Executive_suite.Dining_area state and local variable service:
For each signal you select, modify the properties of what gets captured in the log.
For example, change the logging name of Check_in.Checked_in.Executive_suite.Dining_area to Dining_Room.
For a description of each property, see Properties to Configure for Logging.
The following procedure explains how to log chart signals from the command line.
Open the model that contains the chart.
Get the states whose activity you want to log.
For example, get the Dining_area state in the Hotel chart:
rt = sfroot; da_state = rt.find('-isa','Stateflow.State','Name','Dining_area');
Get the local data you want to log.
For example, get the service local data in the Hotel chart:
svc_data = rt.find('-isa','Stateflow.Data','Name','service');
Enable logging for states and data.
For example, enable logging for the Dining_area state and the service data:
da_state.LoggingInfo.DataLogging = 1; svc_data.LoggingInfo.DataLogging = 1;
Modify logging properties as needed.
For example, change the logged name of the Dining_area state. By default, the logged name is the hierarchical signal name, which is Check_in.Checked_in.Executive_suite.Dining_area. To assign the shorter, custom name of Dining_Room:
% Enable custom naming da_state.LoggingInfo.NameMode = 'Custom'; % Enter the custom name da_state.LoggingInfo.UserSpecifiedLogName = 'Dining_Room';