Main Content

exportToPreviousRelease

Save a Dataset object to a MAT-file you can open in any release

Description

exportToPreviousRelease(ds,filename,dsname) saves the Simulink.SimulationData.Dataset object, ds, to the MAT-file specified by the filename input, using the name specified by the dsname input. You can load the Dataset saved in the file in any release that supports the Dataset format. When you do not use this function to save a Dataset object to a file, you may not be able to load the data in releases prior to R2017a. When you do not need to open and use the Dataset data in a release prior to R2017a, you can use the save function.

example

exportToPreviousRelease(___,version) saves data stored in a Dataset object to a MAT-file you can load in a previous release, using the MAT-file version specified by version.

exportToPreviousRelease(___,'–append') adds data stored in a Dataset object to a MAT-file you can load in a previous release without overwriting the contents of the MAT-file.

exportToPreviousRelease(___,'–nocompression') saves the Dataset object to a MAT-file without compression. The '–nocompression' option only supports Version 7 and Version 7.3 MAT-files.

Examples

collapse all

You can use the exportToPreviousRelease function to save data stored in a Simulink.SimulationData.Dataset object in a MAT-file that you can load in a previous release. This example saves data logged from a simulation in a MAT-file using the exportToPreviousRelease function, and then appends another Dataset object containing data logged from another simulation to the same MAT-file.

Save Dataset Data to a MAT-File

To create a Dataset object containing logged data, run a simulation of the vdp model that logs data for signals x1 and x2. The model is configured to generate a single simulation output containing all simulation data, including the output data stored in the Dataset object yout.

mdl = "vdp";
open_system(mdl)
out = sim(mdl);
yout = out.yout;

Use the exportToPreviousRelease function to save the output data to a MAT-file you can share with colleagues and collaborators who may use different Simulink™ versions.

exportToPreviousRelease(yout,"vdpLoggedData.mat","vdpSim1")

Append Additional Data to the MAT-File

You can use the exportToPreviousRelease function to add data to a MAT-file. For example, if you run another simulation that logs data and get new results that you want to share, you can add these results to your MAT-file. You can load the Dataset object saved using the exportToPreviousRelease function in any release that supports the Dataset format.

set_param("vdp/Mu","Gain","0.5")
out = sim(mdl);
yout = out.yout;

exportToPreviousRelease(yout,"vdpLoggedData.mat","vdpSim2","-append")

Input Arguments

collapse all

Simulink.SimulationData.Dataset object you want to save in a MAT-file and load in a previous release.

Example: logsout

Name of the file to export data to. If the file does not exist, the exportToPreviousRelease function creates the file. When the file exists, you can overwrite the data in the file, or you can use the '–append' input to append the Dataset data to the file.

Example: 'myfile.mat'

Data Types: char | string

Name to use for the Dataset object saved in the MAT-file. The name does not have to match the name of the Dataset object containing the data you want to save in the MAT-file.

Example: 'myLoggedData'

Data Types: char | string

MAT-file version. By default, the exportToPreviousRelease function creates Version 7 MAT-files, unless you have changed the preference for the default MAT-file version created by save operations. For more information, see MAT-File Versions. You cannot save Dataset data to Version 4 MAT-files.

Data Types: char | string

Version History

Introduced in R2019b