comparison m-toolbox/classes/@rational/display.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 % DISPLAY overloads display functionality for rational objects.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: DISPLAY overloads display functionality for rational objects.
5 %
6 % CALL: txt = display(rat)
7 %
8 % INPUT: rat - rational transfer function object
9 %
10 % OUTPUT: txt - cell array with strings to display the rat object
11 %
12 % <a href="matlab:utils.helper.displayMethodInfo('rational', 'display')">Parameters Description</a>
13 %
14 % VERSION: $Id: display.m,v 1.15 2011/04/08 08:56:33 hewitson Exp $
15 %
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17
18 function varargout = display(varargin)
19
20 %%% Check if this is a call for parameters
21 if utils.helper.isinfocall(varargin{:})
22 varargout{1} = getInfo(varargin{3});
23 return
24 end
25
26 objs = utils.helper.collect_objects(varargin(:), 'rational');
27
28 txt = {};
29
30 % Print emtpy object
31 if isempty(objs)
32 hdr = sprintf('------ %s -------', class(objs));
33 ftr(1:length(hdr)) = '-';
34 txt = [txt; {hdr}];
35 txt = [txt; sprintf('empty-object [%d,%d]',size(objs))];
36 txt = [txt; {ftr}];
37 end
38
39 for i=1:numel(objs)
40 banner = sprintf('---- rational %d ----', i);
41 txt{end+1} = banner;
42
43 % get key and value
44 name = objs(i).name;
45 desc = objs(i).description;
46 iunit = char(objs(i).iunits);
47 ounit = char(objs(i).ounits);
48
49 % display
50 txt{end+1} = ['model: ' name];
51 txt{end+1} = ['num: ' mat2str(objs(i).num)];
52 txt{end+1} = ['den: ' mat2str(objs(i).den)];
53 txt{end+1} = ['iunits: ' iunit];
54 txt{end+1} = ['ounits: ' ounit];
55 txt{end+1} = ['description: ' desc];
56 txt{end+1} = ['UUID: ' objs(i).UUID];
57
58 banner_end(1:length(banner)) = '-';
59 txt{end+1} = banner_end;
60 end
61
62 if nargout == 0
63 for ii=1:length(txt)
64 disp(txt{ii});
65 end
66 else
67 varargout{1} = txt;
68 end
69
70 end
71
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 % Local Functions %
74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75
76 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77 %
78 % FUNCTION: getInfo
79 %
80 % DESCRIPTION: Get Info Object
81 %
82 % HISTORY: 11-07-07 M Hewitson
83 % Creation.
84 %
85 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
86
87 function ii = getInfo(varargin)
88 if nargin == 1 && strcmpi(varargin{1}, 'None')
89 sets = {};
90 pl = [];
91 else
92 sets = {'Default'};
93 pl = getDefaultPlist;
94 end
95 % Build info object
96 ii = minfo(mfilename, 'rational', 'ltpda', utils.const.categories.output, '$Id: display.m,v 1.15 2011/04/08 08:56:33 hewitson Exp $', sets, pl);
97 ii.setModifier(false);
98 ii.setOutmin(0);
99 end
100
101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
102 %
103 % FUNCTION: getDefaultPlist
104 %
105 % DESCRIPTION: Get Default Plist
106 %
107 % HISTORY: 11-07-07 M Hewitson
108 % Creation.
109 %
110 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
111
112 function plout = getDefaultPlist()
113 persistent pl;
114 if exist('pl', 'var')==0 || isempty(pl)
115 pl = buildplist();
116 end
117 plout = pl;
118 end
119
120 function pl = buildplist()
121 pl = plist.EMPTY_PLIST;
122 end
123