dsp.MatFileWriter System object

Package: dsp

Write MAT file


The MatFileWriter object writes data to a V7.3 MAT file.

To write data to a V7.3 MAT file:

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

  2. Call step to write data according to the properties of dsp.MatFileWriter. The behavior of step is specific to each object in the toolbox.


H = dsp.MatFileWriter returns a MAT file writer System object, H, that writes data to a V7.3 MAT file.

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

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



Name of MAT file to write

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 write

Name of the variable to which to write. This variable is stored in the MAT file. The default variable name is x. You cannot overwrite a variable that is already in an existing MAT file.


Enable frame-based processing

Set this property to true to enable frame-based processing. Set this property to false to enable sample-based processing. In frame-based mode, this System object streams the data to the first dimension. In sample-based mode, a new dimension is appended to the end of the data set. The default is true.


cloneCreate MAT file writer object with the same property values
isLockedLocked status for input attributes and nontunable properties
releaseAllow property value and input characteristics changes
stepWrite one frame of MAT file data


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

 % First, create a variable name
       filename = [tempname '.mat'];
 % Next, write that variable to a MAT-file.
       hmfw = dsp.MatFileWriter(filename, 'VariableName', 'originalData');
       for i=1:10
           originalData = rand(4,2);
           step(hmfw, originalData);
       release(hmfw); % This will close the MAT file
 % Finally, load the variable back into MATLAB.
       data = load(filename, 'originalData');
Was this topic helpful?