]> Creatis software - CreaPhase.git/blob - octave_packages/control-2.3.52/@lti/frdata.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / control-2.3.52 / @lti / frdata.m
1 ## Copyright (C) 2010, 2011, 2012   Lukas F. Reichlin
2 ##
3 ## This file is part of LTI Syncope.
4 ##
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.
9 ##
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.
14 ##
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/>.
17
18 ## -*- texinfo -*-
19 ## @deftypefn {Function File} {[@var{H}, @var{w}, @var{tsam}] =} frdata (@var{sys})
20 ## @deftypefnx {Function File} {[@var{H}, @var{w}, @var{tsam}] =} frdata (@var{sys}, @var{"vector"})
21 ## Access frequency response data.
22 ## Argument @var{sys} is not limited to frequency response data objects.
23 ## If @var{sys} is not a frd object, it is converted automatically.
24 ##
25 ## @strong{Inputs}
26 ## @table @var
27 ## @item sys
28 ## Any type of LTI model.
29 ## @item "v", "vector"
30 ## In case @var{sys} is a SISO model, this option returns the frequency response
31 ## as a column vector (lw-by-1) instead of an array (p-by-m-by-lw).
32 ## @end table
33 ##
34 ## @strong{Outputs}
35 ## @table @var
36 ## @item H
37 ## Frequency response array (p-by-m-by-lw).  H(i,j,k) contains the
38 ## response from input j to output i at frequency k.  In the SISO case,
39 ## a vector (lw-by-1) is possible as well.
40 ## @item w
41 ## Frequency vector (lw-by-1) in radian per second [rad/s].
42 ## Frequencies are in ascending order.
43 ## @item tsam
44 ## Sampling time in seconds.  If @var{sys} is a continuous-time model,
45 ## a zero is returned.
46 ## @end table
47 ## @end deftypefn
48
49 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
50 ## Created: October 2010
51 ## Version: 0.3
52
53 function [H, w, tsam] = frdata (sys, rtype = "array")
54
55   if (! isa (sys, "frd"))
56     sys = frd (sys);
57   endif
58
59   [H, w] = __sys_data__ (sys); 
60
61   tsam = sys.tsam;
62
63   if (strncmpi (rtype, "v", 1) && issiso (sys))
64     H = reshape (H, [], 1);
65   endif
66
67 endfunction