Home > classes > @ssm > modify.m

modify

PURPOSE ^

modify allows to exectue a string to modify a ssm object

SYNOPSIS ^

function varargout = modify(varargin)

DESCRIPTION ^

 modify allows to exectue a string to modify a ssm object
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: modify allows to exectue a tring to modify a ssm object

 CALL: varargout = modify(varargin)

 INPUTS:
 sys -      (array of) ssm objects
 options -   plist of options:
    'commands' cell array commands to execute
    typical command should be of the type :
            'amats{1,1}(2,3) = -6;'
    and will be executed as :
            'sys(i_sys).amats{1,1}(2,3) = -6;'
    they include no ssm reference, but the semicolon.

 OUTPUTS:
           The output array are of size Nsys*Noptions
 sys_out -  (array of) ssm objects without the modifs

 HISTORY:  05-08-2008 A Grynagier Creation

 M-FILE INFO: Get information about this methods by calling
              >> ssm.getInfo('modify')

              Get information about a specified set-plist by calling:
              >> ssm.getInfo('modify', 'Default')

 TODO :
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 % modify allows to exectue a string to modify a ssm object
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % DESCRIPTION: modify allows to exectue a tring to modify a ssm object
0005 %
0006 % CALL: varargout = modify(varargin)
0007 %
0008 % INPUTS:
0009 % sys -      (array of) ssm objects
0010 % options -   plist of options:
0011 %    'commands' cell array commands to execute
0012 %    typical command should be of the type :
0013 %            'amats{1,1}(2,3) = -6;'
0014 %    and will be executed as :
0015 %            'sys(i_sys).amats{1,1}(2,3) = -6;'
0016 %    they include no ssm reference, but the semicolon.
0017 %
0018 % OUTPUTS:
0019 %           The output array are of size Nsys*Noptions
0020 % sys_out -  (array of) ssm objects without the modifs
0021 %
0022 % HISTORY:  05-08-2008 A Grynagier Creation
0023 %
0024 % M-FILE INFO: Get information about this methods by calling
0025 %              >> ssm.getInfo('modify')
0026 %
0027 %              Get information about a specified set-plist by calling:
0028 %              >> ssm.getInfo('modify', 'Default')
0029 %
0030 % TODO :
0031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0032 
0033 function varargout = modify(varargin)
0034 
0035   %% starting initial checks
0036   utils.helper.msg(utils.const.msg.MNAME, ['running ', mfilename]);
0037 
0038   % Check if this is a call for parameters
0039   if utils.helper.isinfocall(varargin{:})
0040     varargout{1} = getInfo(varargin{3});
0041     return
0042   end
0043 
0044   % Collect input variable names
0045   in_names = cell(size(varargin));
0046   for ii = 1:nargin,in_names{ii} = inputname(ii);end
0047 
0048   % Collect all SSMs and plists
0049   [sys, ssm_invars] = utils.helper.collect_objects(varargin(:), 'ssm', in_names);
0050   pl                = utils.helper.collect_objects(varargin(:), 'plist', in_names);
0051 
0052   options = combine(pl, getDefaultPlist('Default'));
0053   Nsys     = numel(sys);
0054   Noptions = numel(options);
0055   
0056   % Decide on a deep copy or a modify, depending on the output
0057   sys = copy(sys, nargout);
0058   
0059   %% begin function body
0060 
0061   for i_sys=1:Nsys
0062     for i_options=1:Noptions
0063       commands = find(options(i_options), 'commands');
0064       for i_commands=1:length(commands)
0065         strng = ['sys(i_sys,i_options).', commands{i_commands}];
0066         utils.helper.msg(utils.const.msg.MNAME, 'executing command: ');
0067         utils.helper.msg(utils.const.msg.MNAME, strng);
0068         eval(strng);
0069       end
0070       sys(i_sys,i_options) = validate(sys(i_sys,i_options));
0071       sys(i_sys,i_options).addHistory(ssm.getInfo(mfilename), options(i_options) , {''}, sys(i_sys).hist );
0072     end
0073   end
0074   if nargout > 0
0075     varargout{1} = sys;
0076   end
0077 end
0078 
0079 
0080 %--------------------------------------------------------------------------
0081 % Get Info Object
0082 %--------------------------------------------------------------------------
0083 function ii = getInfo(varargin)
0084   if nargin == 1 && strcmpi(varargin{1}, 'None')
0085     sets = {};
0086     pls   = [];
0087   elseif nargin == 1 && ~isempty(varargin{1}) && ischar(varargin{1})
0088     sets{1} = varargin{1};
0089     pls = getDefaultPlist(sets{1});
0090   else
0091     sets = {'Default'};
0092     pls = [];
0093     for kk=1:numel(sets)
0094       pls = [pls getDefaultPlist(sets{kk})];
0095     end
0096   end
0097   % Build info object
0098   ii = minfo(mfilename, 'ssm', '', utils.const.categories.statespace, '$Id: resp.m,v 1.17 2008/07/22 10:22:38 ingo Exp $', sets, pls);
0099 end
0100 
0101 %--------------------------------------------------------------------------
0102 % Get Default Plist
0103 %--------------------------------------------------------------------------
0104 function plo = getDefaultPlist(set)
0105   switch set
0106     case 'Default'
0107       plo = plist( 'commands', {'=ssm;'});
0108     otherwise
0109       error('### Unknown parameter set [%s].', set);
0110   end
0111 end
0112

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003