%% Read MAT File
% 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).
% Read a MAT file using the MatFileReader object.

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

% Copyright 2012 The MathWorks, Inc.