Wednesday, May 9, 2012

Useful matlab commands for large datasets

We were finally able to load the dataset from NYU using the following matlab commands. These may be useful for anyone using datasets with very large matlab files that you can't load all at once into memory.

%% Partial Reading and Writing of MAT Files

%% Looking at what is in the file
% You can use the following to to see what variables are available in your MAT-file

whos -file myBigData

%%  Creating a MAT-File object
% Create a object that corresponds to a MAT-File

matObj = matfile('myBigData.mat');

%% Accessing Variables
% Now you can access variables in the MAT-file as properties of |matObj|,
% with dot notation. This is similar to how you access the fields of
% structures in MATLAB.

loadedData = matObj.X(1:4,1:4);
disp(loadedData)

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Unfortunately, these methods are only available for version R2011b, which is not the version the lab computers at school are running (R2011a).

    http://blogs.mathworks.com/loren/2011/10/14/new-mat-file-functionality-in-r2011b/

    ReplyDelete