set state and description [USAGE] [obj] = state_set_state(<obj>, <state>[, description]); [IN] obj : state object state : state value description : <<string>> explanation of state. [OUT] obj : state object Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [obj] = state_set_state(obj, state, description) 0002 % set state and description 0003 % [USAGE] 0004 % [obj] = state_set_state(<obj>, <state>[, description]); 0005 % [IN] 0006 % obj : state object 0007 % state : state value 0008 % description : <<string>> explanation of state. 0009 % [OUT] 0010 % obj : state object 0011 % 0012 % Copyright (C) 2011, ATR All Rights Reserved. 0013 % License : New BSD License(see VBMEG_LICENSE.txt) 0014 0015 % 0016 % --- Previous check 0017 % 0018 if ~exist('obj', 'var'), error('obj is a required parameter.'); end 0019 if ~exist('state', 'var'), error('state is a required parameter.'); end 0020 if ~exist('description', 'var') 0021 description = []; 0022 end 0023 if ~(isnumeric(state) || islogical(state)) || (length(state) ~= 1) 0024 error('state should be scalar.'); 0025 end 0026 0027 % 0028 % --- Main Procedure 0029 % 0030 obj = struct; 0031 obj.state = state; 0032 obj.description = description; 0033 0034 % 0035 % --- After check 0036 % 0037 if nargout ~= 1 0038 error('function caller should receive obj.'); 0039 end