Main Content

progress

Fraction of files read

Since R2020a

Description

example

fractionRead = progress(sds) returns the fraction of files read in the datastore as a normalized value in the range [0,1].

Examples

collapse all

Specify the path to a set of audio signals included as MAT-files with MATLAB®.

folder = fullfile(matlabroot,'toolbox','matlab','audiovideo');

Create a signal datastore that points to the specified folder and set sample rate variable name to Fs. List the names of the MAT-files in the datastore.

sds = signalDatastore(folder,'FileExtension','.mat','SampleRateVariableName','Fs');
[~,c] = fileparts(sds.Files)
c = 7x1 cell
    {'chirp'   }
    {'gong'    }
    {'handel'  }
    {'laughter'}
    {'mtlb'    }
    {'splat'   }
    {'train'   }

While the signal datastore has unread files, read consecutive files from the datastore. Use the progress function to monitor the fraction of files read.

while hasdata(sds)
    [data,info] = read(sds);
    fprintf('Fraction of files read: %.2f\n',progress(sds))
end
Fraction of files read: 0.14
Fraction of files read: 0.29
Fraction of files read: 0.43
Fraction of files read: 0.57
Fraction of files read: 0.71
Fraction of files read: 0.86
Fraction of files read: 1.00

Print and inspect the info structure returned by the last call to the read function.

info
info = struct with fields:
             SampleRate: 8192
       TimeVariableName: "Fs"
    SignalVariableNames: "y"
               FileName: "/mathworks/devel/bat/filer/batfs1904-0/Bdoc24a.2528353/build/matlab/toolbox/matlab/audiovideo/train.mat"

Input Arguments

collapse all

Specify sds as an signalDatastore object.

Output Arguments

collapse all

Fraction of files read, returned as a normalized value in the range [0,1].

Data Types: double

Version History

Introduced in R2020a