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   % checking number of inputs work data
0045   if ~nargin==2, error('wrong number of inputs!'), end
0046 
0047   if ~isequal(class(varargin{1}),'ssm'), error(['argument is not a ssm but a ', class(varargin{1})]),end
0048   if ~isequal(class(varargin{2}),'plist'), error(['argument is not a plist but a ', class(varargin{2})]),end
0049 
0050   sys = varargin{1};
0051   options = varargin{2};
0052   Nsys     = length(sys);
0053   Noptions = length(options);
0054   %% begin function body
0055 
0056   %% building output depending on options
0057   if Noptions==1
0058     sys_out(:,1) = reshape(sys,Nsys,1);
0059   else
0060     for j=1:Noptions
0061       sys_out(:,j)=copy(reshape(sys,Nsys,1),true);
0062     end
0063   end
0064 
0065   for i_sys=1:Nsys
0066     for i_options=1:Noptions
0067       commands = find(options(i_options), 'commands');
0068       for i_commands=1:length(commands)
0069         strng = ['sys_out(i_sys,i_options).', commands{i_commands}];
0070         utils.helper.msg(utils.const.msg.MNAME, 'executing command: ');
0071         utils.helper.msg(utils.const.msg.MNAME, strng);
0072         eval(strng);
0073       end
0074       sys_out(i_sys,i_options) = validate(sys_out(i_sys,i_options));
0075       sys_out(i_sys,i_options).addHistory(ssm.getInfo(mfilename), options(i_options) , {''}, sys(i_sys).hist );
0076     end
0077   end
0078   varargout = {sys_out};
0079 end
0080 
0081 
0082 function ii = getInfo(varargin)
0083   if nargin == 1 && strcmpi(varargin{1}, 'None')
0084     sets = {};
0085     pls   = [];
0086   elseif nargin == 1 && ~isempty(varargin{1}) && ischar(varargin{1})
0087     sets{1} = varargin{1};
0088     pls = getDefaultPlist(sets{1});
0089   else
0090     sets = {'Default'};
0091     pls = [];
0092     for kk=1:numel(sets)
0093       pls = [pls getDefaultPlist(sets{kk})];
0094     end
0095   end
0096   % Build info object
0097   ii = minfo(mfilename, 'ssm', '', 'STATESPACE', '$Id: resp.m,v 1.17 2008/07/22 10:22:38 ingo Exp $', sets, pls);
0098 end
0099 
0100 function plo = getDefaultPlist(set)
0101   switch set
0102     case 'Default'
0103       plo = plist( 'commands', {'=ssm;'});
0104     otherwise
0105       error('### Unknown parameter set [%s].', set);
0106   end
0107 end
0108

Generated on Mon 25-Aug-2008 22:39:29 by m2html © 2003