LenaH
LenaH

Reputation: 323

Large arrays in Matlab

I am trying to build five single precision arrays of the size 744×744×744×3×3 in the latest MATLAB version (R2016b).

However, when I build the first array, I get the error:

Requested 744x744x744x2x3 (9.2GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information.

I set the workspace preferences in MATLAB to max array size 1e4, which is all that it allows. And I set the maximum virtual memory in Windows 10 to 400GB.

I also read the relevant posts in this forum, but they don't answer my question. Is it impossible to build arrays that size or am I missing something?

Upvotes: 2

Views: 1569

Answers (1)

Maulik Madhavi
Maulik Madhavi

Reputation: 166

You are exceeding your RAM, I can suggest to use matfile.

To save the large matrices (for example My_var, having size Nvar1 x Nvar2), without slowing the other processes...

myObject = matfile('myFilename.mat','Writable',true);
myObject.myVariablenameinObject(1:Nvar1,1:Nvar2)=My_var(1:Nvar1,1:Nvar2)

By setting 'Writable' as true, you can access, modify or write data. If you don't want to write. Just use:

myObject = matfile('myFilename.mat')

For more details, refer to this link.

Upvotes: 1

Related Questions