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 ## @deftypefn {Function File} {[@var{num}, @var{den}, @var{tsam}] =} tfdata (@var{sys})
20 ## @deftypefnx {Function File} {[@var{num}, @var{den}, @var{tsam}] =} tfdata (@var{sys}, @var{"vector"})
21 ## @deftypefnx {Function File} {[@var{num}, @var{den}, @var{tsam}] =} tfdata (@var{sys}, @var{"tfpoly"})
22 ## Access transfer function data.
23 ## Argument @var{sys} is not limited to transfer function models.
24 ## If @var{sys} is not a transfer function, it is converted automatically.
29 ## Any type of LTI model.
30 ## @item "v", "vector"
31 ## For SISO models, return @var{num} and @var{den} directly as column vectors
32 ## instead of cells containing a single column vector.
38 ## Cell of numerator(s). Each numerator is a row vector
39 ## containing the coefficients of the polynomial in descending powers of
40 ## the transfer function variable.
41 ## num@{i,j@} contains the numerator polynomial from input j to output i.
42 ## In the SISO case, a single vector is possible as well.
44 ## Cell of denominator(s). Each denominator is a row vector
45 ## containing the coefficients of the polynomial in descending powers of
46 ## the transfer function variable.
47 ## den@{i,j@} contains the denominator polynomial from input j to output i.
48 ## In the SISO case, a single vector is possible as well.
50 ## Sampling time in seconds. If @var{sys} is a continuous-time model,
51 ## a zero is returned.
55 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
56 ## Created: September 2009
59 function [num, den, tsam] = tfdata (sys, rtype = "cell")
61 if (! isa (sys, "tf"))
65 [num, den] = __sys_data__ (sys);
69 if (! strncmpi (rtype, "t", 1)) # != tfpoly
70 num = cellfun (@get, num, "uniformoutput", false);
71 den = cellfun (@get, den, "uniformoutput", false);
74 if (strncmpi (rtype, "v", 1) && issiso (sys)) # == vector