Mercurial > hg > ltpda
comparison m-toolbox/classes/@ssm/isStable.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 % ISSTABLE tells if ssm is numerically stable | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: ISSTABLE tells if ssm is numerically stable | |
5 % | |
6 % val = sys.isStable | |
7 % | |
8 % <a href="matlab:utils.helper.displayMethodInfo('ssm', 'isStable')">Parameters Description</a> | |
9 % | |
10 % VERSION: $Id: isStable.m,v 1.6 2011/04/08 08:56:23 hewitson Exp $ | |
11 % | |
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
13 | |
14 function varargout = isStable(varargin) | |
15 %%% Check if this is a call for parameters | |
16 if utils.helper.isinfocall(varargin{:}) | |
17 varargout{1} = getInfo(varargin{3}); | |
18 return | |
19 end | |
20 objs = utils.helper.collect_objects(varargin(:), 'ssm'); | |
21 | |
22 utils.helper.msg(utils.const.msg.MNAME, ['running ', mfilename]); | |
23 | |
24 for i=1:numel(objs) | |
25 if ~objs(i).isnumerical % checking system is numeric | |
26 error(['error in double : system named ' objs(i).name ' is not numeric']); | |
27 end | |
28 A = ssm.blockMatFusion(objs(i).amats, objs(i).sssizes, objs(i).sssizes); | |
29 Ts = objs(i).timestep; | |
30 if Ts == 0 | |
31 vp = eig(A); | |
32 f = find(real(vp)>5e-15); | |
33 f2 = find(real(vp)>0); | |
34 display((vp(f))); | |
35 else | |
36 try | |
37 vp = eig(A^1024); | |
38 catch ME | |
39 vp = eig(A); | |
40 end | |
41 f = find(abs(vp)>1+5e-12); | |
42 f2 = find(abs(vp)>1); | |
43 display((vp(f))); | |
44 end | |
45 ninst = numel(f); | |
46 ninst2 = numel(f2); | |
47 isst(i) = ninst==0; | |
48 if ninst>0; | |
49 display(['warning, system named "' objs(i).name '" is not stable']) | |
50 elseif ninst2>0; | |
51 display(['warning, system named "' objs(i).name '" might be numerically unstable']) | |
52 else | |
53 display(['System named "' objs(i).name '" is stable']) | |
54 end | |
55 end | |
56 varargout ={isst}; | |
57 end | |
58 | |
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
60 % Local Functions % | |
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
62 | |
63 | |
64 %-------------------------------------------------------------------------- | |
65 % Get Info Object | |
66 %-------------------------------------------------------------------------- | |
67 function ii = getInfo(varargin) | |
68 | |
69 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
70 sets = {}; | |
71 pl = []; | |
72 else | |
73 sets = {'Default'}; | |
74 pl = getDefaultPlist; | |
75 end | |
76 % Build info object | |
77 ii = minfo(mfilename, 'ssm', 'ltpda', utils.const.categories.output, '$Id: isStable.m,v 1.6 2011/04/08 08:56:23 hewitson Exp $', sets, pl); | |
78 end | |
79 | |
80 %-------------------------------------------------------------------------- | |
81 % Get Default Plist | |
82 %-------------------------------------------------------------------------- | |
83 function pl = getDefaultPlist() | |
84 pl = plist(); | |
85 end | |
86 |