diff m-toolbox/classes/@ssm/ssmFromss.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/@ssm/ssmFromss.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,60 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% FUNCTION:    ssmFromss
+%
+% DESCRIPTION: Construct a ltpda statespace object from a matlab statespace
+%               object
+%
+% CALL:        see ssm, this function is private
+%
+% TODO:        inplement multiple i/o when subassign function is done
+%
+% VERSION :    '$Id: ssmFromss.m,v 1.12 2011/04/08 08:56:22 hewitson Exp $';
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+function sys = ssmFromss(varargin)
+  
+  VERSION = '$Id: ssmFromss.m,v 1.12 2011/04/08 08:56:22 hewitson Exp $';
+  utils.helper.msg(utils.const.msg.MNAME, ['running ', mfilename]);
+  % get info
+  % Set the method version string in the minfo object
+  
+  if nargin ~=2
+    error('ssmFromss need 2 inputs : (obj, plist) ')
+  elseif isa(varargin{1}, 'ss') && isa(varargin{2}, 'plist')
+    pl = varargin{2};
+    ssin = varargin{1};
+  else
+    error('### Please input  (<object>,<plist>)');
+  end
+  
+  sys = ssm.initObjectWithSize(1,1);
+  sys.name = ssin.Name;
+  if ~ isempty(ssin.Notes)
+    sys.description = ssin.Notes;
+  end
+  
+  [a,b,c,d,Ts] = ssdata(ssin) ;
+  sys.amats = {a};
+  sys.bmats = {b};
+  sys.cmats = {c};
+  sys.dmats = {d};
+  sys.timestep = Ts;
+  
+  inputstr = 'input';
+  outputstr = 'output';
+  ssstr =  'state';
+  
+  sys.inputs = ssmblock.makeBlocksWithData({inputstr},{ssin.inputName}, [], [], [] );
+  sys.outputs = ssmblock.makeBlocksWithData({outputstr},{ssin.outputName}, [], [], [] );
+  sys.states = ssmblock.makeBlocksWithData({ssstr}, {ssin.stateName}, [], [], [] );
+  
+  if ~strcmp(pl.find('name'),'None')
+    sys.name = pl.find('name');
+  end
+  if ~strcmp(pl.find('description'),'')
+    sys.description = pl.find('description');
+  end
+  
+end