MATLAB: Deleting Timer Objects containing in Objects’ properties

advanced software devellopementclassdestructor & constructorprogramming fundamentalstimer

Hello,
ich have been trying to delete Timer Object, stored in Object's property before destroying the concerned object. But the Object is deleted and the Timer not. Then any try to delete the timers with help of built-in function "delete" cause matlab to crash. I'm using the following code:
properties
timerCall
end
the Timers' parameter are initialized in constructor. The delete function look like this:
methods
function delete(obj)
delete(obj.timerCall);
end
end
What am I doing wrong? can someone help me?
thanks

Best Answer

See if my code to kill all timers works for you:
%--------------------------------------------------------------------------------------------------------------------------
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
handleToTimer = getappdata(handles.figMainWindow, 'timerObj');
% Stop that timer.
stop(handleToTimer);
% 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