I am working on a statistical model of a content distribution server in MATLAB and have decided to use OO programming. This is my first foray into OO with MATLAB and I have hit a snag. I am attempting to model a download connection to the server, at the moment it is just a MATLAB timer and a boolean. When the timer expires I want to set the isActive
field from true
to false
. So quite simple I feel but then I have been battling with this for more then a day now. Below is the code for the class so far:
classdef dl<handle
properties
isActive = true
ttl = 0
end
methods
function this = startTimer(this, varargin)
this.ttl = timer('TimerFcn', @()killConnection(this), 'StartDelay',1);
start(this.ttl);
end
end
methods (Access = private)
function obj = killConnection(obj, varargin)
obj.isActive = false;
end
end
end