Has anyone got a comment regarding this issue? I really would like to get an update here please, my project depends on this issue in MATLAB.
Cannot clear classes in MATLAB 2013 without closing the session
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I started a project in MATLAB R2010a at the beginning of the year and worked with classes and objects in MATLAB. I discovered a little later that classes are unable to be cleared unless the MATLAB session is closed and reopened. I came upon various questions and answers on the Mathworks questions page:
http://www.mathworks.com/matlabcentral/answers/51648-unable-to-clear-classes http://www.mathworks.com/matlabcentral/answers/48088-inability-to-clear-object-definition-nonfunctional-clear-classes
As for as I could understand, it was reported as a bug and was fixed in MATLAB R2013b. I have thus recently decided to move over to MATLAB R2013b which is available with a license. However, when working in MATLAB 2013, I still came upon the following warnings when trying to clear classes with the clear command:
Warning: Objects of '...' class exist. Cannot
clear this class or any of its superclasses.
> In Main at 27
Warning: Objects of '...' class exist. Cannot
clear this class or any of its superclasses.
> In Main at 27
...
...
Why are these warnings still happening? At the time of running my script called 'Main.m' where the objects are created, all possible windows that use the object (such as any Simulink models) are closed. The only open dialog is Main.m and the command window.
Is it perhaps because the classes that I wrote was written and saved in MATLAB R2010b?
MATLAB R2013b version:
---------------------------------------------------------------------------------------------
MATLAB Version: 8.2.0.701 (R2013b)
MATLAB License Number: 917548
Operating System: Microsoft Windows 7 Version 6.1 (Build 7600)
Java Version: Java 1.7.0_11-b21 with Oracle Corporation Java HotSpot(TM) Client VM mixed mode
---------------------------------------------------------------------------------------------
Example of my class definition:
classdef myClassName < handle
properties
...
end
methods
function obj = myClassName() % Constructor
...
end
end
end
4 comentarios
Matt J
el 28 de Nov. de 2014
You can ignore the warning if you're merely changing the content of a method and not its calling syntax.
I recommend you attach a classdef file that will reproduce the issue. If it can't be reproduced with a simple example, we're probably not going to be able to guess the cause here.
Respuestas (1)
per isakson
el 27 de Nov. de 2014
Editada: per isakson
el 28 de Nov. de 2014
I'm still using R2013a. I encounter this annoying "issue"
- Since R2008a
- When there is still a reference somewhere to some object. I've forgotten to delete a timer or something. That's expected behavior.
- Often during debugging for no obvious reason.
- IIRC, never during production runs.
Bugs have been reported and bugs have been fixed over the years, but the "issue" persists.
 
The release notes of R2014b gave me hope the "issue" is finally history, see Automatic Updates for Modified Classes
[...] MATLAB allows only one definition for a class to exist at any
time. Therefore, all existing objects of a class are updated
automatically to conform to the new class definition. You do not need
to call clear classes to remove existing objects when changing their
defining class.
2 comentarios
Image Analyst
el 27 de Nov. de 2014
In case anyone wants to know how to stop all timers:
function StopTimer(handles)
try
fprintf('Entering StopTimer...\n');
listOfTimers = timerfindall % List all timers, just for info.
% Get handle to the one timer that we should have.
if isempty(listOfTimers)
% Exit if there is no timer to turn off.
fprintf('There are no timers to turn off. Leaving StopTimer().\n');
return;
end
% Delete all timers from memory.
listOfTimers = timerfindall
if ~isempty(listOfTimers)
delete(listOfTimers(:));
end
fprintf('Left StopTimer and turned off all timers.\n');
catch ME
errorMessage = sprintf('Error in StopTimer().\nThe error reported by MATLAB is:\n\n%s', ME.message);
fprintf('%s\n', errorMessage);
uiwait(warndlg(errorMessage));
end
return; % from btnStopTimer_Callback
Adam
el 29 de Nov. de 2014
I can confirm I have seen the automatic updating of classes in action in R2014b. I hadn't read about it in the release notes so it took me quite by surprise when properties I was adding to a class suddenly turned up in an object I currently had created in the main workspace.
I haven't looked into it in any depth, but I have noticed I have not had any of the annoying problems like those described that I used to have regularly in previous versions.
Ver también
Categorías
Más información sobre Call Java from MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!