4

I have a big array (1024x1024x360) and I want to save it to a mat file. When I just try

A=rand(1024,1024,360)
save('filename.mat','A');

The variable is created in the workspace, the file is being created, but it remains empty... I'm using Matlab 2012a on Win7-64 machine, Why is that happening?

Floris
  • 45,857
  • 6
  • 70
  • 122

1 Answers1

6

Earlier versions of Matlab couldn't save variables larger than 2 GB. Your default save file format may be set to an older type even on newer versions of Matlab; my own install of R2013a seems to have come preset to v7, which won't save anything that big. You have two choices: either specify the format for this file using an extra flag:

save('filename.mat','A','-v7.3');

or change the default for all save files by running preferences and looking in the MAT-files area under General.

nhowe
  • 909
  • 6
  • 14
  • 3
    +1 just be aware that v7.3 is based on HDF5 format unlike previous versions: [MATLAB: Differences between .mat versions](http://stackoverflow.com/questions/4950630/matlab-differences-between-mat-versions) – Amro Apr 26 '13 at 01:08