MATLAB: How to create variable in MAT file that is too large to fit in memory

matfilememory

The new 2011b release provides the matfile object, allowing you to load a portion of a large MAT-file variable using indices. This is useful if the entire variable cannot fit in memory.
But my question is, how can I create such a large variable in a MAT file in the first place, if I cannot construct it entirely in memory first? The save -append option only adds variables to a file; it does not append elements to a variable in the file.
I see that the matfile object allows for partial save (by indices) in the same manner as partial read, so if I could somehow allocate such a large variable (like a zeros() for matfile), then I could write to it piecemeal.

Best Answer

So, I finally got the answer I was looking for at an on-campus MATLAB seminar not too long ago. If I have a matfile object, matObj, then preallocating a large variable is as simple as:
matObj.myVar(1000:1000) = 0;
I also just googled and found a blog post by Loren Shure that demonstrates this: http://blogs.mathworks.com/loren/2011/10/14/new-mat-file-functionality-in-r2011b/#17