Out of memory error: problem loading large .mat file

Hi,
I have a .mat file containing just one big Simulink.ModelDataLogs variable. The names are "myfile.mat" and "mylogsout".
When I try to load this .mat file into the workspace, I receive the error:
"Out of memory. Type HELP MEMORY for your options".
I tried to use the "matfile" command, as
matObj = matfile('myfile.mat');
but this way I can't acess the inner variables in "mylogsout", as
data = matObj.mylogsout.Signal_In.Force.Data;
I want to find a way to load only the variables from the "mylogsout" file that I will use in script.
How can I load only specific variables of the "mylogsout" file? Is it possible?
Thanks,
Marcelo

5 commentaires

I tried the load(filename,variables) command and it didn't work.
The problem is that my .mat file has just one variable, which is the Simulink.ModelDataLogs variable. I want to load some specific parts of this variable, not the entire Simulink.ModelDataLogs.
BTW, are you using a 64 bit version of MATLAB or 32 Bit? 64 would definitely help. If this is already the case, you can either add more memory (RAM/virtual RAM through harddisk), or load the file on a larger machine, split the variable in multiple variables and save again ...
Titus
I'm using a 32 Bit version of Matlab.
Yes, split the Simulink.ModelDataLogs variable probably will work.
I will try do that before I save the .mat file.
I am having the same problem, with almost the same situation. I have a matfile with a lot of simulink simulation data (72G) that I am trying to load using the MATFILE command. I thought that was the whole point of using the MATFILE command instead of LOAD...to avoid loading the whole file into memory at once? But it appears to be attempting to load the entire 72G file into memory on my 16G machine, and matlab just crashes and exits silently.
I'm using 64 bit matlab.
Is this a bug or expected behavior?

Connectez-vous pour commenter.

Réponses (1)

Jan
Jan le 9 Jan 2015

1 vote

The message means, that the computer does not have enough free memory to store the variable. Is it possible to free memory e.g. by clearing unused variables or stopping other applications? Increasing the virtual memory can help also, but the best method is installing more RAM.
It is possible to create a MEX function, which imports specific fields of a struct only. But I'm convinced that the development and testing is more expensive than buying 4GB of additional RAM.

3 commentaires

Jan,
This memory error sometimes occurred even with the workspace completely cleared.
If I could read just specific parts of the Simulink.ModelDataLogs variable, I think this problem would be reduced.
Dear Jan,
All variables in Workplace could be saved as a .mat file. It is about 1.2GB. However, as I load it, it is opened incompletely. Some variables miss. Matlab warns "Out of memory". How can it be fixed?
I am using 128GB RAM.
Thank you,
If Matlab runs out of memory, either the arrays occupy much more memory than the MAT files. This is possible, because MAT files are compressed such that zeros(1,1e9) does not need 8e9 bytes in the MAT file. Or the RAM is exhausted by other data already, such that even 1.2MB do not fit anywhere.
Check the contents of the MAT file and the available RAM. Use:
whos
whos -file YourFile.mat

Connectez-vous pour commenter.

Catégories

Produits

Question posée :

le 8 Jan 2015

Commenté :

Jan
le 3 Fév 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by