1 ## Copyright (C) 2011 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{z}, @var{p}, @var{k}, @var{tsam}] =} zpkdata (@var{sys})
20 ## @deftypefnx {Function File} {[@var{z}, @var{p}, @var{k}, @var{tsam}] =} zpkdata (@var{sys}, @var{"v"})
21 ## Access zero-pole-gain data.
26 ## Any type of LTI model.
27 ## @item "v", "vector"
28 ## For SISO models, return @var{z} and @var{p} directly as column vectors
29 ## instead of cells containing a single column vector.
35 ## Cell of column vectors containing the zeros for each channel.
36 ## z@{i,j@} contains the zeros from input j to output i.
38 ## Cell of column vectors containing the poles for each channel.
39 ## p@{i,j@} contains the poles from input j to output i.
41 ## Matrix containing the gains for each channel.
42 ## k(i,j) contains the gain from input j to output i.
44 ## Sampling time in seconds. If @var{sys} is a continuous-time model,
45 ## a zero is returned.
49 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
50 ## Created: September 2011
53 function [z, p, k, tsam] = zpkdata (sys, rtype = "cell")
55 [num, den, tsam] = tfdata (sys);
57 z = cellfun (@roots, num, "uniformoutput", false);
58 p = cellfun (@roots, den, "uniformoutput", false);
59 k = cellfun (@(n,d) n(1)/d(1), num, den);
61 if (strncmpi (rtype, "v", 1) && issiso (sys))