How to create variable in MAT file that is too large to fit in memory?
Mostrar comentarios más antiguos
The new 2011b release provides the matfile object, allowing you to load a portion of a large MAT-file variable using indices. This is useful if the entire variable cannot fit in memory.
But my question is, how can I create such a large variable in a MAT file in the first place, if I cannot construct it entirely in memory first? The save -append option only adds variables to a file; it does not append elements to a variable in the file.
I see that the matfile object allows for partial save (by indices) in the same manner as partial read, so if I could somehow allocate such a large variable (like a zeros() for matfile), then I could write to it piecemeal.
1 comentario
Oleg Komarov
el 7 de Sept. de 2011
Not such a great addition then...
Respuesta aceptada
Más respuestas (2)
James Tursa
el 7 de Sept. de 2011
1 voto
You could create the MAT file from scratch in a Fortran or C/C++ program using the published uncompressed MAT file format. E.g., here:
A variable of the desired size doesn't have to exist in memory in order for the MAT file to be written.
1 comentario
Jeff
el 13 de Sept. de 2011
the cyclist
el 7 de Sept. de 2011
0 votos
One simple possibility is that the large array was created and saved when it was the only variable in the workspace, but later is loaded when the workspace is littered with other variables, so there is only room for part of it.
2 comentarios
Jeff
el 7 de Sept. de 2011
Walter Roberson
el 7 de Sept. de 2011
Or the large array was constructed on a system which had more memory, including possibly a 64 bit MATLAB version for a file being loaded on a 32 bit MATLAB version.
Subnote: if you are planning to use such large matrices, you should probably be saving with -v7.3 as your files might be too large for -v7 . But beware that -v7.3 file performance can be much worse than -v7 file performance (unless they fixed that.)
Categorías
Más información sobre Text Files en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!