Just adding getter/setter methods on my program makes my program super slow. Is there any explanation for this?
function set.x(obj,newx)
obj.x = newx;
end
function x = get.x(obj)
x = obj.x;
end
That's how I define them under my handle class. Or have I just not implemented them correctly?
Edit
class definition goes...
classdef sensorlocest < handle
properties(GetAcess = 'public', SetAccess = 'private')
sensorId; % sensor id
X; % true x-coordainate
Y; % true y-coordinate
x; % estimate of X
y; % estimate of Y
end
methods
function sesnors = sensorlocest(x,y)
if nargin ~= 0
sesnors(49,1) = sensorlocest;
for k = 1:length(sensors)
sensors(k).sesnorId = k;
sensors(k).X = x.*rand;
sensors(k).Y = y.*rand;
end
end
function init(sensors,x,y)
N = length(sensors);
for i = 1:N
sensors(i).x = x.*rand;
sensors(i).y = y.*rand;
end
end
function set.x(sensors,newx)
sensors.x = newx;
end
function set.y(sensors,newy)
sensors.y = newy;
end
end
end