1 ## Copyright (C) 2009, 2010, 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{re}, @var{im}, @var{w}] =} nyquist (@var{sys})
20 ## @deftypefnx {Function File} {[@var{re}, @var{im}, @var{w}] =} nyquist (@var{sys}, @var{w})
21 ## Nyquist diagram of frequency response. If no output arguments are given,
22 ## the response is printed on the screen.
27 ## LTI system. Must be a single-input and single-output (SISO) system.
29 ## Optional vector of frequency values. If @var{w} is not specified,
30 ## it is calculated by the zeros and poles of the system.
31 ## Alternatively, the cell @code{@{wmin, wmax@}} specifies a frequency range,
32 ## where @var{wmin} and @var{wmax} denote minimum and maximum frequencies
39 ## Vector of real parts. Has length of frequency vector @var{w}.
41 ## Vector of imaginary parts. Has length of frequency vector @var{w}.
43 ## Vector of frequency values used.
46 ## @seealso{bode, nichols, sigma}
49 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
50 ## Created: November 2009
53 function [re_r, im_r, w_r] = nyquist (sys, w = [])
55 ## TODO: multiplot feature: nyquist (sys1, "b", sys2, "r", ...)
57 if (nargin == 0 || nargin > 2)
61 [H, w] = __frequency_response__ (sys, w, false, 0, "ext");
63 H = reshape (H, [], 1);
68 plot (re, im, "b", re, -im, "r")
70 xlim (__axis_margin__ (xlim))
71 ylim (__axis_margin__ (ylim))
73 title (["Nyquist Diagram of ", inputname(1)])
75 ylabel ("Imaginary Axis")