annotate scripts/control/base/nyquist.m @ 5307:4c8a2e4e0717

[project @ 2005-04-26 19:24:27 by jwe]
author jwe
date Tue, 26 Apr 2005 19:24:47 +0000
parents 32c569794216
children 500d884ae373
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
1 ## Copyright (C) 1996, 1998 Auburn University. All rights reserved.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
2 ##
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
4 ##
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by the
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
7 ## Free Software Foundation; either version 2, or (at your option) any
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
8 ## later version.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
9 ##
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but WITHOUT
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
11 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
13 ## for more details.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
14 ##
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, write to the Free
5307
4c8a2e4e0717 [project @ 2005-04-26 19:24:27 by jwe]
jwe
parents: 5215
diff changeset
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
4c8a2e4e0717 [project @ 2005-04-26 19:24:27 by jwe]
jwe
parents: 5215
diff changeset
18 ## 02110-1301 USA.
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
19
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
20 ## -*- texinfo -*-
3500
7923abdeb4e5 [project @ 2000-01-31 06:35:00 by jwe]
jwe
parents: 3462
diff changeset
21 ## @deftypefn {Function File} {[@var{realp}, @var{imagp}, @var{w}] =} nyquist (@var{sys}, @var{w}, @var{out_idx}, @var{in_idx}, @var{atol})
7923abdeb4e5 [project @ 2000-01-31 06:35:00 by jwe]
jwe
parents: 3462
diff changeset
22 ## @deftypefnx {Function File} {} nyquist (@var{sys}, @var{w}, @var{out_idx}, @var{in_idx}, @var{atol})
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
23 ## Produce Nyquist plots of a system; if no output arguments are given, Nyquist
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
24 ## plot is printed to the screen.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
25 ##
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
26 ## Compute the frequency response of a system.
5016
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4771
diff changeset
27 ##
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
28 ## @strong{Inputs} (pass as empty to get default values)
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
29 ## @table @var
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
30 ## @item sys
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
31 ## system data structure (must be either purely continuous or discrete;
5016
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4771
diff changeset
32 ## see @code{is_digital})
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
33 ## @item w
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
34 ## frequency values for evaluation.
5016
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4771
diff changeset
35 ## If sys is continuous, then bode evaluates @math{G(@var{jw})};
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4771
diff changeset
36 ## if sys is discrete, then bode evaluates @math{G(exp(@var{jwT}))},
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4771
diff changeset
37 ## where @var{T} is the system sampling time.
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
38 ## @item default
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
39 ## the default frequency range is selected as follows: (These
5016
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4771
diff changeset
40 ## steps are @strong{not} performed if @var{w} is specified)
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
41 ## @enumerate
5016
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4771
diff changeset
42 ## @item via routine @command{__bodquist__}, isolate all poles and zeros away from
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
43 ## @var{w}=0 (@var{jw}=0 or @math{exp(@var{jwT})=1}) and select the frequency
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
44 ## range based on the breakpoint locations of the frequencies.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
45 ## @item if @var{sys} is discrete time, the frequency range is limited
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
46 ## to @var{jwT} in
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
47 ## @ifinfo
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
48 ## [0,2p*pi]
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
49 ## @end ifinfo
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
50 ## @iftex
5016
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4771
diff changeset
51 ## @tex
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4771
diff changeset
52 ## $ [ 0,2 p \pi ] $
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4771
diff changeset
53 ## @end tex
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
54 ## @end iftex
5016
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4771
diff changeset
55 ## @item A ``smoothing'' routine is used to ensure that the plot phase does
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
56 ## not change excessively from point to point and that singular
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
57 ## points (e.g., crossovers from +/- 180) are accurately shown.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
58 ## @end enumerate
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
59 ## @item atol
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
60 ## for interactive nyquist plots: atol is a change-in-slope tolerance
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
61 ## for the of asymptotes (default = 0; 1e-2 is a good choice). This allows
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
62 ## the user to ``zoom in'' on portions of the Nyquist plot too small to be
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
63 ## seen with large asymptotes.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
64 ## @end table
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
65 ## @strong{Outputs}
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
66 ## @table @var
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
67 ## @item realp
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
68 ## @itemx imagp
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
69 ## the real and imaginary parts of the frequency response
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
70 ## @math{G(jw)} or @math{G(exp(jwT))} at the selected frequency values.
5016
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4771
diff changeset
71 ## @item w
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
72 ## the vector of frequency values used
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
73 ## @end table
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
74 ##
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
75 ## If no output arguments are given, nyquist plots the results to the screen.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
76 ## If @var{atol} != 0 and asymptotes are detected then the user is asked
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
77 ## interactively if they wish to zoom in (remove asymptotes)
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
78 ## Descriptive labels are automatically placed.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
79 ##
5016
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4771
diff changeset
80 ## Note: if the requested plot is for an @acronym{MIMO} system, a warning message is
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
81 ## presented; the returned information is of the magnitude
5016
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4771
diff changeset
82 ## @iftex
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4771
diff changeset
83 ## @tex
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4771
diff changeset
84 ## $ \Vert G(jw) \Vert $ or $ \Vert G( {\rm exp}(jwT) \Vert $
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4771
diff changeset
85 ## @end tex
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4771
diff changeset
86 ## @end iftex
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4771
diff changeset
87 ## @ifinfo
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4771
diff changeset
88 ## ||G(jw)|| or ||G(exp(jwT))||
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4771
diff changeset
89 ## @end ifinfo
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4771
diff changeset
90 ## only; phase information is not computed.
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
91 ## @end deftypefn
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
92
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
93 ## Author: R. Bruce Tenison <btenison@eng.auburn.edu>
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
94 ## Created: July 13, 1994
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
95 ## A. S. Hodel July 1995 (adaptive frequency spacing,
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
96 ## remove acura parameter, etc.)
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
97 ## Revised by John Ingram July 1996 for system format
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
98
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
99 function [realp, imagp, w] = nyquist (sys, w, outputs, inputs, atol)
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
100
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
101 ## Both bode and nyquist share the same introduction, so the common
3438
2e06c3941943 [project @ 2000-01-14 06:33:18 by jwe]
jwe
parents: 3431
diff changeset
102 ## parts are in a file called __bodquist__.m. It contains the part that
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
103 ## finds the number of arguments, determines whether or not the system
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
104 ## is SISO, andd computes the frequency response. Only the way the
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
105 ## response is plotted is different between the two functions.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
106
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
107 ## check number of input arguments given
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
108 if (nargin < 1 | nargin > 5)
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
109 usage("[realp,imagp,w] = nyquist(sys[,w,outputs,inputs,atol])");
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
110 endif
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
111 if(nargin < 2)
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
112 w = [];
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
113 endif
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
114 if(nargin < 3)
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
115 outputs = [];
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
116 endif
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
117 if(nargin < 4)
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
118 inputs = [];
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
119 endif
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
120 if(nargin < 5)
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
121 atol = 0;
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
122 elseif(!(is_sample(atol) | atol == 0))
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
123 error("atol must be a nonnegative scalar.")
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
124 endif
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
125
3438
2e06c3941943 [project @ 2000-01-14 06:33:18 by jwe]
jwe
parents: 3431
diff changeset
126 ## signal to __bodquist__ who's calling
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
127
3455
f758be6e1730 [project @ 2000-01-18 19:57:12 by hodelas]
hodelas
parents: 3438
diff changeset
128 [f, w, sys] = __bodquist__ (sys, w, outputs, inputs, "nyquist");
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
129
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
130 ## Get the real and imaginary part of f.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
131 realp = real(f);
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
132 imagp = imag(f);
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
133
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
134 ## No output arguments, then display plot, otherwise return data.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
135 if (nargout == 0)
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
136 dnplot = 0;
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
137 while(!dnplot)
4422
92be67bc9301 [project @ 2003-06-04 17:43:15 by jwe]
jwe
parents: 3502
diff changeset
138 oneplot();
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5016
diff changeset
139 __gnuplot_set__ key;
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
140 clearplot();
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
141 grid ("on");
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5016
diff changeset
142 __gnuplot_set__ data style lines;
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
143
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
144 if(is_digital(sys))
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
145 tstr = " G(e^{jw}) ";
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
146 else
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
147 tstr = " G(jw) ";
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
148 endif
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
149 xlabel(["Re(",tstr,")"]);
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
150 ylabel(["Im(",tstr,")"]);
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
151
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
152 [stn, inn, outn] = sysgetsignals(sys);
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
153 if(is_siso(sys))
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
154 title(sprintf("Nyquist plot from %s to %s, w (rad/s) in [%e, %e]", ...
4771
b8105302cfe8 [project @ 2004-02-16 17:45:50 by jwe]
jwe
parents: 4422
diff changeset
155 inn{1}, outn{1}, w(1), w(length(w))) )
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
156 endif
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
157
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5016
diff changeset
158 __gnuplot_set__ nologscale xy;
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
159
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
160 axis(axis2dlim([[vec(realp),vec(imagp)];[vec(realp),-vec(imagp)]]));
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
161 plot(realp,imagp,"- ;+w;",realp,-imagp,"-@ ;-w;");
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
162
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
163 ## check for interactive plots
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
164 dnplot = 1; # assume done; will change later if atol is satisfied
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
165 if(atol > 0 & length(f) > 2)
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
166
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
167 ## check for asymptotes
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
168 fmax = max(abs(f));
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
169 fi = max(find(abs(f) == fmax));
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
170
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
171 ## compute angles from point to point
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
172 df = diff(f);
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
173 th = atan2(real(df),imag(df))*180/pi;
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
174
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
175 ## get angle at fmax
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
176 if(fi == length(f)) fi = fi-1; endif
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
177 thm = th(fi);
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
178
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
179 ## now locate consecutive angles within atol of thm
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
180 ith_same = find(abs(th - thm) < atol);
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
181 ichk = union(fi,find(diff(ith_same) == 1));
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
182
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
183 ## locate max, min consecutive indices in ichk
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
184 loval = max(complement(ichk,1:fi));
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
185 if(isempty(loval)) loval = fi;
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
186 else loval = loval + 1; endif
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
187
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
188 hival = min(complement(ichk,fi:length(th)));
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
189 if(isempty(hival)) hival = fi+1; endif
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
190
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
191 keep_idx = complement(loval:hival,1:length(w));
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
192
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
193 if(length(keep_idx))
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
194 resp = input("Remove asymptotes and zoom in (y or n): ",1);
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
195 if(resp(1) == "y")
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
196 dnplot = 0; # plot again
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
197 w = w(keep_idx);
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
198 f = f(keep_idx);
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
199 realp = real(f);
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
200 imagp = imag(f);
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
201 endif
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
202 endif
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
203
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
204 endif
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
205 endwhile
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
206 w = [];
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
207 realp=[];
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
208 imagp=[];
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
209 endif
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
210
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
211 endfunction