Main Content

Simulink.sdi.exportRun

Export Simulation Data Inspector run data to workspace or file

Description

dataset = Simulink.sdi.exportRun(runID) exports data from one or more Simulation Data Inspector runs identified by runID to the Simulink.SimulationData.Dataset object dataset.

Use Simulink.sdi.exportRun when you have access to the run ID, or when you want to export multiple runs. When you want to export a single run and have the Simulink.sdi.Run object, use export.

To include data from multiple runs in the Dataset object, specify the runID input as a vector of run IDs. (since R2023a)

example

Simulink.sdi.exportRun(runID,Name=Value) exports the data to the base workspace or a file according to the options specified by one or more name-value pair arguments. You can export data for one or more runs to a MAT file, MLDATX file, Microsoft® Excel® file, or a Parquet file.

Examples

collapse all

Suppose you want to export data from Simulation Data Inspector runs and have not generated a Run object in your script. To return a column vector of all run IDs in the Simulation Data Inspector repository, use Simulink.sdi.getAllRunIDs.

runIDs = Simulink.sdi.getAllRunIDs;

To export all run data in the Simulation Data Inspector to a Dataset object in the workspace, use the vector of run IDs as input for the Simulink.sdi.exportRun function.

allSDIRuns = Simulink.sdi.exportRun(runIDs);

When you want to export data from only a single run, use the corresponding run ID for that run. For example, export only data from the most recent run in the Simulation Data Inspector.

latestRunID = runIDs(end);
latestSDIRun = Simulink.sdi.exportRun(latestRunID);

Input Arguments

collapse all

Run identifier for the run you want to export to the workspace or a file.

The Simulation Data Inspector assigns a unique run ID to each run. You can get the run ID for one or more runs using Simulink.sdi.getAllRunIDs and Simulink.sdi.getRunIDByIndex.

You can export more than one run to the workspace or a file by specifying the runID input as a vector of Simulation Data Inspector run IDs. (since R2023a)

Name-Value Arguments

expand all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: "To","file"

Export to File

expand all

Where to export data, specified as one of these options:

  • "variable" — Export one or more signals to a workspace variable.

  • "file" — Export one or more signals to a MAT file, a Microsoft Excel file, an MP4 file, an MLDATX file, or a Parquet file.

    When you export data to a file, you must also specify a filename using the Filename name-value argument.

    When you export a run to a MAT file, the data is saved in a Simulink.SimulationData.Dataset object. When you export more than one run to a MAT file using the Simulink.sdi.exportRun function, the data is saved in a Dataset object, where each element is a Dataset object that contains the data for one exported run.

Example: export(mySigObj,To="file",Filename="mySpreadsheet.xlsx")

Name and type of file to which to export data, specified as a string or character vector. Include a file extension to specify the type of file.

  • .mat — MAT file

  • .mldatx — MLDATX file

  • .xlsxMicrosoft Excel file

  • .mp4 — MP4 file

  • .parquet — Parquet file

When you do not specify an extension with a file name, the data exports to a MAT file.

To specify the Filename name-value argument, you must specify the To name-value argument as "file".

Example: Filename="mySpreadsheet.xlsx"

Tips

  • When you export one signal to a MAT file, the data is saved in the MAT file as a timeseries object.

  • When you export multiple signals to a MAT file, the data is saved as a Simulink.SimulationData.Dataset object that contains a Simulink.SimulationData.Signal object for each exported signal.

  • Data exported to a Microsoft Excel file is saved using the format described in Microsoft Excel Import, Export, and Logging Format.

  • When you export data to a Microsoft Excel file, you can specify additional options using the overwrite, metadata, and sharetimecolumn name-value arguments.

  • When you export data to a Parquet file, you can configure shared or individual time columns, set row groups by height or size, and choose the compression used when saving the file using the Parquet File Options name-value arguments.

  • Data exported to a Parquet file is saved using the format described in Parquet File Logging Format for Simulation Data

Microsoft Excel File Options

expand all

Data to overwrite in existing Microsoft Excel file, specified as one of these options:

  • "file" — Overwrite the entire file with the exported data.

  • "sheetsonly" — Overwrite only sheets of the Microsoft Excel file that contain data that corresponds to the exported data.

Specify the Overwrite name-value argument only when you export data to a Microsoft Excel file.

When you export data to an existing MAT file or Parquet file, the exported data overwrites the entire file.

Example: Overwrite="sheetsonly"

Metadata to include in the exported Microsoft Excel file, specified as a string array. By default, the exported file does not include any metadata. You can export this metadata to a Microsoft Excel file:

  • dataType — Signal data type

  • units — Signal units

  • blockPath — Path to the source block for logged signals

  • interp — Signal interpolation method

  • portIndex — Index of the port on the source block for logged signals

The order of metadata options in the string array does not determine the order of the metadata in the exported file, which always matches the description in Microsoft Excel Import, Export, and Logging Format.

Example: Metadata=["units" "dataType"]

Option for signals that have identical time data to share time columns in the exported Microsoft Excel, specified as "on" or "off". By default, signals that have identical time data share a time column in the exported file. When you specify the value as "off", each signal in the exported file has its own time column.

Example: ShareTimeColumn="off"

Parquet File Options

expand all

Since R2026a

Option to generate JSON sidecar that contains all the logged metadata, specified as "on" or "off". Specify the ParquetMetadata name-value argument only when you export data to a Parquet file.

Option for signals that have identical time data to share time columns in the exported Parquet file, specified as "on" or "off". By default, signals that have identical time data share a time column in the exported file. When you specify the value as "off", each signal in the exported file has its own time column.

Example: ShareTimeColumn="off"

Since R2026a

Parquet file compression, specified as one of these options:

  • "fastest" — Similar save speed to an uncompressed file, smaller file size

  • "balanced" — Balance between file size and save speed

  • "compact" — Smallest file size, slowest save speed

  • "none" — Largest file size, fastest save speed

Example: export(mySigObj,To="file",Filename="myFile.parquet",ParquetCompression="balanced")

Since R2026a

Row grouping policy in Parquet file, specified as one of these options:

  • "height" — Define the row group by specifying the number of rows per group.

  • "sizeinmb — Define the row group by specifying the size of the row group in megabytes.

Example: export(mySigObj,To="file",Filename="myFile.parquet",ParquetRowGroupPolicy="sizeinmb")

Since R2026a

Number of rows in row group, specified as "auto" or an integer between 1 and 67,108,864. By default, the value is "auto", which creates the largest possible row group without exceeding 512 MB.

To specify the row group height, ParquetRowGroupPolicy must be "height".

Example: export(mySigObj,To="file",Filename="myFile.parquet",ParquetRowGroupPolicy="height",ParquetRowGroupHeight=500)

Since R2026a

Row group size in megabytes, specified as a positive integer less than or equal to 1024. By default the row group size is 512 MB.

To specify the row group size, ParquetRowGroupPolicy must be "sizeinmb".

Example: export(mySigObj,To="file",Filename="myFile.parquet",ParquetRowGroupPolicy="sizeinmb",ParquetRowGroupsize=256)

Output Arguments

collapse all

Exported run data, returned as a Simulink.SimulationData.Dataset object in the workspace. Do not return an output argument when you export data to a file.

Version History

Introduced in R2017a

expand all