simscape.logging.export
Save logged simulation data in MLDATX file
Description
simscape.logging.export(
saves
the simlog
,fileName
)simlog
object, containing logged simulation
data, for future use. You can use this function only for data logged
with the Stream data to temporary disk directory preference
turned on.
When you stream simulation data to disk, the data is stored as a simlog
object in a temporary file, and the workspace logging variable references the
simlog
object. The temporary file persists as long as there is a
logging variable in the workspace that references the file. This function lets you save the
simlog
object to a permanent file, specified by the
fileName
argument, in MLDATX format.
Examples
Save Logged Simulation Data Streamed to Disk
To enable streaming data to disk, on the MATLAB® Toolstrip, click Preferences. In the left pane of the Preferences dialog box, select Simscape, then select the Stream data to temporary disk directory check box.
Open the Permanent Magnet DC Motor example model, which already has data logging enabled, and run the simulation:
openExample('simscape/PermanentMagnetDCMotorExample') sim('PermanentMagnetDCMotor');
During the simulation, logged data is streamed to disk, to a temporary file. After
the simulation, you see the simulation log variable
simlog_PermanentMagnetDCMotor
(as specified by the
Workspace variable name model configuration parameter) in your
current workspace:
simlog_PermanentMagnetDCMotor
simlog_PermanentMagnetDCMotor = Node with properties: id: 'PermanentMagnetDCMotor' savable: 0 exportable: 1 DC_Motor: [1×1 simscape.logging.Node] MRRef_Motor: [1×1 simscape.logging.Node] ERef: [1×1 simscape.logging.Node] Load_Torque: [1×1 simscape.logging.Node] Step_Input: [1×1 simscape.logging.Node] DC_Voltage: [1×1 simscape.logging.Node] MRRef_Torque: [1×1 simscape.logging.Node] Sensing: [1×1 simscape.logging.Node]
The exportable: 1
property of the
simlog_PermanentMagnetDCMotor
variable indicates that this variable
points to the temporary file on disk, which contains the simulation data. The temporary
file exists as long as the variable exists in your workspace, then it is deleted.
To save the logged simulation data for future use, type:
simscape.logging.export(simlog_PermanentMagnetDCMotor,'C:\Work\motor_run1');
This command creates a file under C:\Work
, named
motor_run1.mldatx
, and stores the logged simulation data in this
file, in MLDATX format.
To retrieve the logged simulation data at a later time and associate
it with a workspace variable, use the simscape.logging.import
function.
Input Arguments
simlog
— Logged simulation data
Node
object
Logged simulation data, specified as a Node
object, with the
exportable
property set to 1
. You refer to the
simlog
object by the name of the corresponding simulation log
workspace variable. You specify the name of the simulation log variable by using the
Workspace variable name parameter in the
Simscape pane of the Configuration Parameters dialog box.
fileName
— File name and path
character vector | string scalar
File name and path, specified as a character vector or string scalar. The function stores the
simlog
object in the specified file, in MLDATX format. You can omit
the file extension. If you do not include the path, the file resides in the current
working directory.
If the file already exists, the function overwrites it without a warning. However, if you import a node from a file, and then try to export it to the same file, a message informs you that in this case the file cannot be overwritten.
Example: 'C:\Work\motor_run1.mldatx'
Data Types: char
| string
Version History
Introduced in R2016aR2024a: HDF5 (H5) file format for exporting logged simulation data has been removed
In R2020b, the default format for exporting logged simulation data has been changed from
HDF5 to MLDATX, but you could still export HDF5 files. This functionality has now been
removed. If you specify a file extension other than .mldatx
, you get an
error.
R2020b: File format when storing logged simulation data steamed to disk has changed from HDF5 to MLDATX
In R2020b, the file format for streaming logged simulation data to disk has changed, and
as a result, the default format for simscape.logging.export
and
simscape.logging.import
has also changed from HDF5 to MLDATX.
However, you can still export and import HDF5 files:
When you use
simscape.logging.export
without specifying the file extension, the data is stored in an MLDATX file in the temporary directory.Currently, you can still export data in HDF5 format, to share it with colleagues who are using older software releases. To do this, specify
.h5
file extension when usingsimscape.logging.export
. The function stores the data in HDF5 format and issues a warning that this functionality will be removed in a future release. If you specify a file extension other than.h5
or.mldatx
, you get an error.When you import an H5 file from a previous release using
simscape.logging.import
, the data is automatically loaded into theNode
object and copied to a file in the temporary directory. If there are two files with the same name and different extensions (H5 and MLDATX), then the MLDATX file is loaded.
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)