exportToPreviousRelease

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

Description

example

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.

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 ex_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 signal logging data stored in the Dataset object, logsout.

open_system('ex_vdp.slx')
out = sim('ex_vdp');
logsout = out.logsout;

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

exportToPreviousRelease(logsout,'vdpLoggedData.mat','ex_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 you want to share. You can load the Dataset object saved using the exportToPreviousRelease function in any release that supports the Dataset format.

set_param('ex_vdp/Mu','Gain','0.5')
out = sim('ex_vdp');
logsout = out.logsout;

exportToPreviousRelease(logsout,'vdpLoggedData.mat','ex_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 (MATLAB). You cannot save Dataset data to Version 4 MAT-files.

Data Types: char | string

Introduced in R2019b