Peterstone
Peterstone

Reputation: 7449

Matlab: Is it possible to save in the workspace a vector that contains 4 millions of values?

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.

Upvotes: 1

Views: 716

Answers (3)

Mikhail Poda
Mikhail Poda

Reputation: 5832

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.

Upvotes: 1

Matteo De Felice
Matteo De Felice

Reputation: 1518

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.

Upvotes: 2

Ghaul
Ghaul

Reputation: 3330

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')

Upvotes: 1

Related Questions