Where is the workspace saved?

9 次查看(过去 30 天)
Pretty straightforward question I guess. Where is the workspace held, in my computer? Is it on the RAM, on the hard drive, or a combination of both?
Is any form of "workspace management" useful? Such as clearing unused variables, or avoiding to keep a lot of huge variables loaded at the same time?

采纳的回答

Image Analyst
Image Analyst 2016-9-16
The workspace is saved in RAM memory. You can also save it to disk to a mat file if you call save(). The main functions for cleaning up are clc, clear, close, and delete. Each of those has several options so check them out in the help. One way to clean up most stuff is
clc;
close all force;
clear all;
clear global;
You can make a shortcut on your toolbar called "Clean up" to do all that. It's often recommended to make such a button by Mathworks trainers.
  2 个评论
Patrick Aoun
Patrick Aoun 2016-9-16
Thanks! That definitely explains why my parfor loop is obliterating my RAM...
Stephen23
Stephen23 2016-9-16
编辑:Stephen23 2016-9-16
"Is any form of "workspace management" useful?"
MATLAB intelligently looks after memory, allocating and freeing it up as needed. Good programming practices (such as writing functions rather than scripts, and keeping data together as much as possible) make explicitly clearing data unnecessary. In a few edge-cases this memory management might do something unexpected, but generally you should just leave it up to MATLAB.
If you have some very large arrays and need to clear them otherwise you will run out of memory, then by all means do so. Just keep in mind what the clear documentation says: "Calling clear all, clear classes, and clear functions decreases code performance, and is usually unnecessary." You might like to read about clearvars, which is more useful than clear for clearing variables.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Workspace Variables and MAT-Files 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by