我有一段别人编的代码不是很明白,希望大神能够帮我解释几个问题
背景:这是作者自己编的函数addSVO 括号内的(obj,id,class,svos) 四个量,后三个我都可以在程序里找到设置。但obj这个我不是很理解。
所以后面出现的"obj.****"这个要怎么理解呢?
是说的这一大类么?不是很懂。重点是那个“.”是什么用途啊?
function addSVO(obj,id,class,svos)
if obj.update_flag
ME = MException('fim:addSVO:invalidAction',...
'Cannot add SVO after a call to update has been made.');
throw(ME);
elseif nargin < 3
ME = MException('fim:addSVO:notEnoughInputs',...
'Not enough input arguments.');
throw(ME);
elseif all([1 2] ~= class)
ME = MException('fim:addSVO:invalidInput',...
'class must be either 1 or 2');
throw(ME);
elseif ~ischar(id) || any(strcmpi(obj.ids,id))
ME = MException('fim:addSVO:invalidInput',...
'id must be a unique string');
throw(ME);
elseif ~isa(svos,'SVO')
ME = MException('fim:addSVO:invalidInput',...
'Last input must belong to the class "SVO"');
throw(ME);
elseif svos.nx ~= obj.nx
ME = MException('fim:addSVO:invalidInput',...
'The given SVO must have a number of states equal to %d',obj.nx);
throw(ME);
end
if strcmpi(id,'nominal')
if class ~= 1
ME = MException('fim:addSVO:invalidInput',...
'Nominal SVO must be class 1.');
throw(ME);
end
obj.nml = obj.nSVO+1;
elseif strcmpi(id,'global')
if class ~= 1
ME = MException('fim:addSVO:invalidInput',...
'Global SVO must be class 1.');
throw(ME);
end
obj.glb = obj.nSVO+1;
%options.approximation = 'hypercube'; %this property is used
%in fim:update during the nominal mode operation
end
obj.nSVO = obj.nSVO + 1;
obj.SVObank = [obj.SVObank;
svos];
obj.ids = [obj.ids;id];
obj.classes = [obj.classes;class];
if class == 1
%Class 1 SVOs are active by default
obj.active = [obj.active;1];
else
obj.active = [obj.active;0];
end
end