when "clear all" does not clear all?

조회 수: 24 (최근 30일)
Naum Derzhi
Naum Derzhi 2017년 3월 27일
답변: Steven Lord 2020년 7월 8일
Hello. Sometimes I have a problem with modifying a class file. After I modify the file containing a class description, I run >> clear all The workspace becomes empty, I do not see any Matlab objects anywhere. However, when I try to instantiate the class, I sometimes (with annoying frequency) get a message that the class file had been modified and modifications will not take effect until I clear all objects of this class. Since I see not objects in the workspace, I do not know what to clear. I repeat "clear all" many times with no effect. Usually in this case I have to exit from Matlab and start it again. This is inconvenient, to say the least.
The class does not have static or constant properties. Or global properties, for that matter. Or persistent.
Any ideas would be greatly appreciated.
Thank you,
N. Derzhi
  댓글 수: 1
David Goodmanson
David Goodmanson 2017년 3월 27일
Hello Naum, You might want to try 'clear classes'. See 'help clear' for information.

댓글을 달려면 로그인하십시오.

답변 (2개)

Pulkit Goel
Pulkit Goel 2020년 7월 8일
I faced similar issue, where after editing the class, I was initializing object of older calss. Running following commands helped me with the issue
clear classes
clear pcode
rehash path
rehash toolboxcache

Steven Lord
Steven Lord 2020년 7월 8일
One potential reason why you may be unable to clear a class is if an instance is stored in a property in a figure window, potentially inside an anonymous function.
obj = myClass;
f = figure;
f.UserData = obj;
clear all % obj and f are deleted, but the figure remains open
clear classes % the instance inside the figure UserData prevents myClass from being cleared

카테고리

Help CenterFile Exchange에서 Scope Variables and Generate Names에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by