Mercurial > hg > ltpda
comparison m-toolbox/classes/@ssm/ssmFromMiir.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
2 % | |
3 % FUNCTION: ssmFromMiir | |
4 % | |
5 % DESCRIPTION: Construct a statespace model from a miir | |
6 % | |
7 % CALL: see ssm, this function is private | |
8 % | |
9 % TODO: check must be made there is no pole zero cancelation | |
10 % | |
11 % VERSION : '$Id: ssmFromMiir.m,v 1.26 2011/03/23 20:05:37 adrien Exp $'; | |
12 % | |
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
14 | |
15 function varargout = ssmFromMiir(varargin) | |
16 | |
17 | |
18 VERSION = '$Id: ssmFromMiir.m,v 1.26 2011/03/23 20:05:37 adrien Exp $'; | |
19 utils.helper.msg(utils.const.msg.MNAME, ['running ', mfilename]); | |
20 % get info | |
21 ii = ssm.getInfo('ssm', 'from miir'); | |
22 % Set the method version string in the minfo object | |
23 ii.setMversion([VERSION '-->' ii.mversion]); | |
24 | |
25 if nargin ~=2 | |
26 error('ssmFromss need 2 inputs : (obj, plist) ') | |
27 elseif isa(varargin{1}, 'miir') && isa(varargin{2}, 'plist') | |
28 pl = combine(varargin{2}, ii.plists); | |
29 miirsin = varargin{1}; | |
30 else | |
31 error('### Please input (<object>,<plist>)'); | |
32 end | |
33 | |
34 ssmout = ssm.initObjectWithSize(size(miirsin,1),size(miirsin,2)); | |
35 for i =1:numel(miirsin) | |
36 num = miirsin(i).a; | |
37 den = miirsin(i).b; | |
38 num = num/den(1); | |
39 den = den/den(1); | |
40 Nss = size(den,2)-1; | |
41 if length(num)<Nss+1 | |
42 num = [zeros(1,Nss+1-length(num)) num]; | |
43 end | |
44 [q,r] = deconv(num,den);%polynmial division for den = conv(num,q)+r . | |
45 if ~length(q)==1 | |
46 error('system may be non caussal'); | |
47 end | |
48 | |
49 ssmout(i).dmats = {q}; | |
50 ssmout(i).amats = {[zeros(Nss-1,1) eye(Nss-1); fliplr(-den(2:(Nss+1)))]}; | |
51 ssmout(i).bmats = {zeros(Nss,1)}; | |
52 if Nss>0 | |
53 ssmout(i).bmats{1}(Nss) = 1; | |
54 end | |
55 ssmout(i).cmats = {fliplr(r(2:(Nss+1)))}; | |
56 | |
57 ssmout(i).name = miirsin(i).name; | |
58 ssmout(i).timestep = 1/(miirsin(i).fs); | |
59 | |
60 inputstr = 'input'; | |
61 outputstr = 'output'; | |
62 ssstr = 'state'; | |
63 | |
64 ssmout(i).inputs = ssmblock.makeBlocksWithData({inputstr},[],{{inputstr}}, {miirsin(i).iunits},[] ); | |
65 ssmout(i).outputs = ssmblock.makeBlocksWithData({outputstr},[],{{outputstr}}, {miirsin(i).ounits},[] ); | |
66 ssmout(i).states = ssmblock.makeBlocksWithSize(Nss, ssstr); | |
67 | |
68 ssmout(i).addHistory(ii, pl, {''}, miirsin(i).hist); | |
69 | |
70 if ~strcmp(pl.find('name'),'None') | |
71 ssmout(i).name = pl.find('name'); | |
72 end | |
73 if ~strcmp(pl.find('description'),'') | |
74 ssmout(i).description = pl.find('description'); | |
75 end | |
76 | |
77 end | |
78 | |
79 varargout = {ssmout}; | |
80 end | |
81 | |
82 |