Storing data in RAM?

11 visualizaciones (últimos 30 días)
Adam
Adam el 26 de Jun. de 2013
Hello
I am using MATLAB in conjunction with a finite-element simulation program (COMSOL) that solves for some physics with a time-stepping method. How it works is basically for each time-step in COMSOL, it executes my MATLAB function and returns the output. My MATLAB function is modeling a complex process and its output depends on many variables from within my function from the previous timestep. However, variables from inside of a function are lost after the function returns its output, so I need to store them somewhere. I have been saving them to a .mat file at the end of my function call and loading them from that .mat file at the start of my function call as a means to communicate this data between the different timesteps. This method was working fine for 2-D finite element simulations, however in 3-D simulations the variable sizes are much larger and the saving loading time becomes too large.
My variables.mat file that I am loading is ~25 MB, containing 2 structures, 2 1x1 doubles, a 1x1 scatteredInterpolant, a 200x1 double, a 50000x1 double, and a 50000x200 double. It takes approximately 17 seconds to load this .mat file from the hard drive and 1 second to save it (on a computer with 64GB RAM and dual Intel Xeon X5690 processors). These loading times are far too large for my simulation to run in a reasonable amount of time, as COMSOL may need to compute hundreds of timesteps.
I am looking for a way to store these variable in the RAM somehow, rather than saving or loading from the hard drive. Or possibly find a way to keep variables from a function saved in the workspace, although I'm not sure this method would work because COMSOL may be opening a "new" MATLAB session for each time-step/function call.
Is there a way to keep track of 6 or 7 variables from within a function, other than to load and save them from the hard drive?
Any help is greatly appreciated, Thanks!

Respuesta aceptada

Sean de Wolski
Sean de Wolski el 26 de Jun. de 2013
doc persistent
?

Más respuestas (0)

Categorías

Más información sobre Nonlinear Dynamics en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by