Save function is taking too long and Execution cannot be stopped

58 views (last 30 days)
I'm trying to save some very large variables and testing out various ways of saving them that might best work for my workflow.
However often the save function ends up doing nothing and the command is not completed and cannot be broken with CTRL+C forcing me to force quit matlab with the task manager, which then means many hours of reloading the data back into the workspace (which is why I want to save these variables in the first place)
When you force quit matlab a window pops up and asks if I want to "stop now and exit". Is there any way to utilise this stop now aspect without actually exiting and losing the workspace?

Answers (1)

Amit Dhakite
Amit Dhakite on 5 Jun 2023
Hi Nadav,
As per my understanding, you want to save very large variables in a file, but the operation is not completed and takes too long.
For your query regarding force quitting MATLAB, unfortunately there is no way to preserve the variables after the MATLAB closes, unless the process of saving them completes.
However, to improve the speed of saving large variables in a file, you may want to consider utilizing a 3rd party function called “savefast()”.
Please keep in mind that while this function has been developed and shared by a MATLAB user on the MathWorks File Exchange, it is not a built-in part of MATLAB and is not directly supported by MathWorks. You can learn more about "savefast()" and its applications through the link provided here: https://www.mathworks.com/matlabcentral/fileexchange/39721-save-mat-files-more-quickly
  1 Comment
Walter Roberson
Walter Roberson on 5 Jun 2023
Or you could
save(FileName, Variables..., '-v7', '-nocompression')
If you are saving large enough objects you would need -v7.3
Note that -v7.3 is generally significantly slower than -v7 if you have struct or cell array or any other composite datatype

Sign in to comment.

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!