I am working with a very computational expansive code in Matlab. It requires the usage of optimisation techniques and long computations using very big matrixes.
I am having the following issue: even if the code run correctly, at the end of the iterations required by the code, Matlab is not storing the biggest cell arrays that I have. I guess that it is due to some memory inefficiency in my code or with my computer (which is probably not sufficiently powerful). However, I followed all the general suggestions in the Matlab documentation and it is still not working.
Using evalc, I managed to save a different variable for each iteration of the code, in order to re-create the original matrix at the end of the loop. However, using:
- evalc(strcat('var_', mat2str(i), '=varTmp'));
- evalc(strcat('save(var_', mat2str(i), '-append)'));
- clear var*
.. in this way it is working, but it still slow and not very "clean and tidy".
Is there a way to do the same thing in a better way (consider that I have to do the same thing for several variables with different names and dimensions) or i.e. to update a cell array in a .mat file adding a column (row or whatever) without loading it?
Thanks