dsp.MatFileReader class

Package: dsp

Read MAT file


The MatFileReader object reads V7.3 MAT files.

To read V7.3 MAT files:

  1. Define and set up your System object™. See Construction.

  2. Call step to read the MAT file according to the properties of dsp.MatFileReader. The behavior of step is specific to each object in the toolbox.


H = dsp.MatFileReader returns a System object, H, to read data from a V7.3 MAT file.

H = dsp.MatFileReader('PropertyName',PropertyValue,...) returns a MAT file reader System object, H, with each specified property set to the specified value.

H = dsp.MatFileReader(FILENAME,VARIABLENAME'PropertyName',PropertyValue,...) returns a MAT file reader System object, H, with the Filename property set to FILENAME, the VariableName property set to VARIABLENAME, and other specified properties set to the specified values.



Name of MAT file from which to read

Specify the name of a MAT file as a string. Specify the full path for the file only if the file is not on the MATLAB® path. The default file name is Untitled.mat.


Name of the variable to read

Name of the variable stored in and read from the MAT file. The default variable name is x.


Number of samples per output frame

Specify the number of elements to read from the MAT file each time the step method is called. The default number of samples per frame is 1.


cloneCreate MAT file reader object with same property values
isDoneEnd-of-file status
isLockedLocked status (logical) for input attributes and nontunable properties
releaseAllow property value and input characteristics changes
resetReset internal states of multimedia file reader to read from beginning of file
stepRead data from a variable in the MAT file


Use dsp.MatFileReader and dsp.MatFileWriter to stream data.

filename = [tempname '.mat'];  % Create variable name
originalData = rand(40,2);
save(filename,'originalData','-v7.3'); % Write to MAT file
H = dsp.MatFileReader(filename,'VariableName',...
   'originalData','SamplesPerFrame', 4);  
while ~isDone(H)         % Stream data into MATLAB
    finalData = step(H);
Was this topic helpful?