Documentation

启动信号测井模型

Enable and Disable Logging at the Model Level

记录一个信号,马克日志。为维etails, seeConfigure a Signal for Logging.

Enable or disable logging globally for all signals that you mark for logging in a model. By default, signal logging is enabled. Simulink®logs signals only if theConfiguration Parameters>Data Import/Export>Signal loggingparameter is checked. If the option is not checked, Simulink ignores the signal logging settings for individual signals.

When signals are marked for logging, the signal data is logged to the workspace and also sent directly to the Simulation Data Inspector, by default. You can disable logging signals to the workspace through the Configuration Parameters dialog box or programmatically.

  • In the Configuration Parameters dialog box, clear theConfiguration Parameters>Data Import/Export>Signal loggingparameter check box.

  • From the command line, use theSignalLoggingparameter.

    set_param(bdroot,'SignalLogging','off')

Data for signals marked for logging is always sent to the Simulation Data Inspector.

Selecting a Subset of Signals to Log

You can select a subset of signals to log for a model that has:

  • Signal logging enabled

  • Logged signals

为维etails, seeOverride Signal Logging Settings.

Specify Format for Dataset Signal Elements

Logged signal data is saved inDatasetformat (asSimulink.SimulationData.Datasetobjects). To specify whether you want the data for individual signals in the dataset to use MATLAB®timeseriesortimetableelements, set theDataset signal formatconfiguration parameter. The default istimeseries. For details, seeDataset signal format.

Migrate Scripts That Use LegacyModelDataLogsAPI

For scripts that simulate a model created in a release earlier than R2016a that usesModelDataLogsformat for logging, update the code to log inDatasetformat.

If you have already logged signal data in theModelDataLogsformat, you can use theSimulink.ModelDataLogs.convertToDatasetfunction to update theModelDataLogssignal logging data to useDatasetformat. For example, to update theolder_model_datasetfromModelDataLogsformat toDatasetformat:

new_dataset = logsout.convertToDataset('older_model_data')

Converting a model from usingModelDataLogsformat to usingDatasetformat can require that you modify your existing models and to code in callbacks, functions, scripts, or tests. The following table identifies possible issues to address after converting toDatasetformat. The table provides solutions for each issue.

Possible Issue After Conversion to Dataset Format Solution

Code in existing callbacks, functions, scripts, or tests that used theModelDataLogsprogrammatic interface to access data can result in an error.

Check for code that usesModelDataLogsformat access methods. Update that code to useDatasetformat access methods.

For example, suppose that existing code includes the following line:

logsout.('Subsystem Name').X.data

Replace that code with aDatasetaccess method:

logsout.getElement('x').Values.data

Muxblock signal names are lost.

TheDatasetformat treatsMuxblock signals as a vector. To identify signals by signal names, replaceMuxblocks withBus Creatorblocks.

信号观众cannot be used for signal logging.

Simulink does not log signal logging data in the Signal Viewer.

Use the signal logging output variable to view the logged data.

Theunpackmethod generates an error.

Theunpackmethod, which is supported forSimulink.ModelDataLogsandSimulink.SubsysDataLogsobjects, isnotsupported forSimulink.SimulationData.Datasetobjects.

For example, if the data inmloghas three fields:x,y, andz, then:

ForModelDataLogsformat data, themlog.unpackmethod creates three variables in the base workspace.

ForDatasetformat data, access methods by names. For example:

x = logsout.getElement('x').Values

TheModelDataLogsandDatasetformats have different naming rules for unnamed signals.

If necessary, add signal names.

InModelDataLogsformat, for an unnamed signal coming from a block, Simulink assigns a name in this form:

SL_BlockName+

For example,SL_Gain1.

InDatasetformat, elements do not need a name, so Simulink leaves the signal name empty.

For bothModelDataLogsandDatasetformats, Simulink assigns the same name to unnamed signals that come fromBus Selectorblocks.

Test points in referenced models are not logged.

Consider enabling signal logging for test points in a referenced model.

Script useswhoorwhosfunctions.

Consider usingSimulink.SimulationData.Dataset.findinstead.

Specify a Name for Signal Logging Data

You use the model-level signal logging name to access the signal logging data for a model. The default name for the signal logging data islogsout. Specifying a model-level signal logging name can make it easier to identify the source of the logged data. For example, you could specify the signal logging namecar_logsoutto identify the data as being the signal logging data for thecarmodel.

To specify a different model-level signal logging name, use either of these approaches:

  • In the edit box next to theConfiguration Parameters>Data Import/Export>Signal loggingparameter, enter the signal logging name.

  • Use theSignalLoggingNameparameter, specifying a signal logging name. For example:

    set_param(bdroot,'SignalLoggingName','heater_model_signals')

Related Topics