MatLab OOP不改变属性
我有一个属性为“next state”的matlab类 我在类中定义了以下函数:MatLab OOP不改变属性,matlab,oop,Matlab,Oop,我有一个属性为“next state”的matlab类 我在类中定义了以下函数: function obj = decideNextAction(obj) obj.current_patch_quality % Important, rand is redeclared in the two calls. So it may be % that rand < current_patch_quality in the f
function obj = decideNextAction(obj)
obj.current_patch_quality
% Important, rand is redeclared in the two calls. So it may be
% that rand < current_patch_quality in the first if and greater
% than in the second if
if(rand > obj.current_patch_quality)
obj.next_action = 1;
elseif(rand < obj.current_patch_quality)
obj.next_action = 3;
else
obj.next_action = 2;
end
end
您必须在
classdef
中使用handleclass
:
classdef myclass < handle
classdef myclass < handle
x = x.decideNextAction();