Main Content


Return percentage of data read from datastore



p = progress(dst) returns the percentage, as a number between 0 and 1, of the data that you have read from the datastore object dst. For example, a return value of 0.55 means that you have read 55% of the data. Use the progress function and the NumSamples property to determine the current read position.


collapse all

When you have a object that contains big data from a simulation, you can use the read function to read chunks of data to incrementally process your data. The progress function returns the percentage of data that has been read from the datastore.

Log Big Data from Model

Open the example model sldemo_fuelsys.

mdl = "sldemo_fuelsys";

Select Configuration Parameters > Data Import/Export > Log Dataset data to file. Alternatively, you can use the set_param function to log simulation data logged using the Dataset format to a MAT-file instead of the workspace.


Simulate the model.


The MAT-file out.mat appears in your current folder. Logged signal data is stored in the MAT-file with the variable name sldemo_fuelsys_out.

Create a DatasetRef object that refers to the logged signal data.

DSRef = Simulink.SimulationData.DatasetRef("out.mat","sldemo_fuelsys_output");

Read Data and Check Progress

Use curly braces to return a SimulationDatastore representation of the fuel signal, which is the tenth element in the DatasetRef object DSRef. The SimulationDatastore object exists in the Values property of the returned Signal object.

SimDataSig = DSRef{10};
DStore = SimDataSig.Values;

The NumSamples property returns the total number of samples in the datastore.

ans = uint64

Set the ReadSize property of Dstore to 200. Then, read from the datastore 10 times. Each read operation advances the reading position by 200 samples.

DStore.ReadSize = 200;
for i = 1:10

Use the progress function to determine the percentage of the total datastore that has been read.

ans = 0.0098

Input Arguments

collapse all

Input datastore, specified as a object.

Output Arguments

collapse all

Percentage of data read from the datastore, returned as a number between 0 and 1.

Data Types: double

Version History

Introduced in R2017a