Does MATLAB keep some variables after clearing?

自古美人都是妖i 提交于 2019-12-12 07:51:14

问题


I have a program that reads in a really large Excel file and creates some large variables. This runs out of storage if I try to run it multiple times in a row, which makes sense, i.e.:

large_program; large_program

will crash. However, what I don't understand is why

large_program; clear all; large_program

will also crash; in order to run it multiple times, I have to restart MATLAB each time. Does MATLAB not actually clear all variables? Or is this a fragmentation of memory thing?


回答1:


Matlab can indeed hold onto some variables and other settings "under the hood". I have the following set up as a short-cut to purge it back to a "just switched on" state (the one that can really catch you out is that clear functions is not a subset of clear all).

restoredefaultpath;
clc;
clear all;
close all;
clear functions;
bdclose('all');
fclose('all');


来源:https://stackoverflow.com/questions/11477918/does-matlab-keep-some-variables-after-clearing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!