Configure States and Local Data for Logging

Properties to Configure for Logging

You can configure the same properties for logging states and local data in a chart as you can for logging signals in a model:

PropertyDescription
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 nameName 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 lastLimits the amount of data logged to the most recent samples. See Limit Data Points to Last in the Simulink documentation.
Decimation valueLimits 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.

See Also

Choose a Configuration Method for Logging

There are several ways to configure states and local data for logging:

MethodWhen to Use
Log Individual States and DataConfigure states or local data for logging one at a time from inside the chart.
Log Multiple Signals At OnceConfigure multiple signals for logging from a list of all states and local data.
Log Chart Signals Using the Command-Line APIConfigure logging properties programmatically.

Log Individual States and Data

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.

  1. Open the properties dialog box for the state or local data.

    For:Do This:
    StatesRight-click the state and select Properties.
    Local data

    Right-click the state or transition that uses the local data and select Explore > (data) variable_name.

  2. In the properties dialog box, click the Logging tab.

  3. Modify properties as needed, as described in Properties to Configure for Logging.

For example, from the Hotel chart of the sf_semantics_hotel_checkinsf_semantics_hotel_checkin model:

  1. Open the properties dialog box for the service local data and select the Log signal data check box.

  2. 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.

See Also

Log Multiple Signals At Once

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.

  1. 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.

  2. 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:

  3. 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.

Log Chart Signals Using the Command-Line API

The following procedure explains how to log chart signals from the command line.

  1. Open the model that contains the chart.

    For example, open the sf_semantics_hotel_checkinsf_semantics_hotel_checkin model, which has a chart called Hotel.

  2. 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');
  3. 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;
  4. 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';

See Also

Log Multiple Signals At Once

Was this topic helpful?