1 ## Copyright (C) 2009, 2010, 2011, 2012 Lukas F. Reichlin
3 ## This file is part of LTI Syncope.
5 ## LTI Syncope is free software: you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation, either version 3 of the License, or
8 ## (at your option) any later version.
10 ## LTI Syncope is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ## GNU General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>.
19 ## Display routine for TF objects.
21 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
22 ## Created: September 2009
25 function display (sys)
27 sysname = inputname (1);
28 [inname, outname, tsam] = __lti_data__ (sys.lti);
30 [inname, m] = __labels__ (inname, "u");
31 [outname, p] = __labels__ (outname, "y");
36 [num, den] = filtdata (sys);
43 disp (["Transfer function '", sysname, "' from input '", inname{nu}, "' to output ..."]);
46 __disp_frac__ (num{ny, nu}, den{ny, nu}, sys.tfvar, outname{ny});
50 display (sys.lti); # display sampling time
53 disp ("Static gain.");
55 disp ("Continuous-time model.");
57 disp ("Discrete-time model.");
63 function __disp_frac__ (num, den, tfvar, name)
65 MAX_LEN = 12; # max length of output name
67 tfp = isa (num, "tfpoly");
69 if (num == tfpoly (0))
70 str = [" ", name, ": 0"];
71 elseif ((tfp && den == 1) || (! tfp && isequal (den, 1)))
72 ## elseif (den == tfpoly (1)) doesn't work because it
73 ## would mistakingly accept non-tfpoly denominators like [0, 1]
74 str = [" ", name, ": "];
75 numstr = tfpoly2str (num, tfvar);
77 ##elseif (length (den) == 1) # de-comment for non-development use
78 ## str = [" ", name, ": "];
79 ## num = num * (1/get (den));
80 ## numstr = tfpoly2str (num, tfvar);
81 ## str = [str, numstr];
83 numstr = tfpoly2str (num, tfvar);
84 denstr = tfpoly2str (den, tfvar);
85 fracstr = repmat ("-", 1, max (length (numstr), length (denstr)));
87 str = strjust (strvcat (numstr, fracstr, denstr), "center");
89 namestr = name(:, 1 : min (MAX_LEN, end));
90 namestr = [namestr, ": "];
91 namestr = strjust (strvcat (" ", namestr, " "), "left");
92 namestr = horzcat (repmat (" ", 3, 1), namestr);