This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

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.

    Note:   Starting in R2016b, instead of using the step method to perform the operation defined by the System object, you can call the object with arguments, as if it were a function. For example, y = step(obj,x) and y = obj(x) perform equivalent operations.


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 character vector. 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.


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


expand all

Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent step syntax. For example, myObject(x) becomes step(myObject,x).

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');

Introduced in R2012b

Was this topic helpful?