Preallocating a large array in a MATLAB matfile with something other than zeroes
问题 I need to write an array that is too large to fit into memory to a .mat binary file. This can be accomplished with the matfile command, which allows random access to a .mat file on disc. I am trying to preallocate the array in this file, and the approach recommended by a MathWorks blog is matObj = matfile('myBigData.mat','Writable',true); matObj.X(10000,10000) = 0; This works, but leaves me with a large array of zeroes - which is risky, as some of the genuine values that I will be populating