1

I am calculating something and, as result I have a vector 4 millions elements. I am not still finished to calculate it. I´ve calculate it will take 2 and a half hours more. When I will have finished I could save it? It is not possible, what can I do? Thank you.

Peterstone
  • 7,119
  • 14
  • 41
  • 49
  • what do you want to do? To stop a calculation and continue it later? Otherwise you case use save command (as Ghaul replied). – Matteo De Felice Mar 19 '11 at 17:30
  • I just want to know if a vector with so many elements could be saved by saving the workspace. – Peterstone Mar 19 '11 at 17:35
  • That will of course depend on your computer, but 4 million is not that big, so most modern computers should handle it. – Ghaul Mar 19 '11 at 22:52

3 Answers3

2

On Windows 32-bit you can have at maximum a double array of 155-200 millions of elements. Check other OSs on Mathworks support page.

Matteo De Felice
  • 1,488
  • 9
  • 23
1

Yes, just use the command save. If you just need it for later Matlab computations, then it is best to save it in .mat format.

save('SavedFile.mat','largeVector')

You can then load your file whenever you need it using the load function.

load('SavedFile.mat')
Ghaul
  • 3,340
  • 1
  • 19
  • 24
  • Thank you for writting by I don´t consider this answer as a good answer. This response don´t answer my question. – Peterstone Mar 19 '11 at 12:18
1

On my machine it takes 0.01 sec to get a random vector with 4 million elements, with whos you can see that it takes (only) 32 MB.

It would take only few seconds to save such amount of data with MATLAB. If you are working with post-R2007b then maybe it is better to save with '-v7.3' option, newer MATLAB versions use by default general HDF5 format but there could be some performance/disc usage issues.

Community
  • 1
  • 1
Mikhail Poda
  • 5,742
  • 3
  • 39
  • 52