progress - Return percentage of data read from datastore - MATLAB (original) (raw)
Main Content
Return percentage of data read from datastore
Syntax
Description
[p](#bvozbys-1-p) = progress([dst](#bvozbys-1-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 of0.55
means that you have read 55% of the data. Use theprogress
function and the NumSamples
property to determine the current read position.
Examples
When you have a matlab.io.datastore.SimulationDatastore
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
_f
uelsys
.
mdl = "sldemo_fuelsys"; open_system(mdl)
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.
set_param(mdl,"LoggingToFile","on")
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.
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 read(DStore); end
Use the progress
function to determine the percentage of the total datastore that has been read.
Input Arguments
Input datastore, specified as a matlab.io.datastore.SimulationDatastore
object.
Output Arguments
Percentage of data read from the datastore, returned as a number between0
and 1
.
Data Types: double
Version History
Introduced in R2017a