annotate scripts/control/base/bode.m @ 7475:aa5208636bea

Fixes for quiver3
author Kostas Poulios
date Tue, 12 Feb 2008 16:32:37 -0500
parents a1dbe9d80eee
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
1 ## Copyright (C) 1996, 1998, 2000, 2003, 2004, 2005, 2006, 2007
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
2 ## Auburn University. All rights reserved.
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
3 ##
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
4 ## This file is part of Octave.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
5 ##
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
6 ## Octave is free software; you can redistribute it and/or modify it
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6447
diff changeset
7 ## under the terms of the GNU General Public License as published by
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6447
diff changeset
8 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6447
diff changeset
9 ## your option) any later version.
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
10 ##
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6447
diff changeset
11 ## Octave is distributed in the hope that it will be useful, but
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6447
diff changeset
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6447
diff changeset
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6447
diff changeset
14 ## General Public License for more details.
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
15 ##
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
16 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6447
diff changeset
17 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6447
diff changeset
18 ## <http://www.gnu.org/licenses/>.
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 -*-
3501
8b21bcbc1080 [project @ 2000-01-31 06:43:15 by jwe]
jwe
parents: 3500
diff changeset
21 ## @deftypefn {Function File} {[@var{mag}, @var{phase}, @var{w}] =} bode (@var{sys}, @var{w}, @var{out_idx}, @var{in_idx})
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
22 ## If no output arguments are given: produce Bode plots of a system; otherwise,
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
23 ## compute the frequency response of a system data structure
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
24 ##
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
25 ## @strong{Inputs}
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
26 ## @table @var
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
27 ## @item sys
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
28 ## a system data structure (must be either purely continuous or discrete;
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
29 ## see is_digital)
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
30 ## @item w
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
31 ## frequency values for evaluation.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
32 ##
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
33 ## if @var{sys} is continuous, then bode evaluates @math{G(jw)} where
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
34 ## @math{G(s)} is the system transfer function.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
35 ##
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
36 ## if @var{sys} is discrete, then bode evaluates G(@code{exp}(jwT)), where
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
37 ## @itemize @bullet
3502
b5238ac1dca9 [project @ 2000-01-31 07:40:53 by jwe]
jwe
parents: 3501
diff changeset
38 ## @item @math{T} is the system sampling time
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
39 ## @item @math{G(z)} is the system transfer function.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
40 ## @end itemize
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
41 ##
3500
7923abdeb4e5 [project @ 2000-01-31 06:35:00 by jwe]
jwe
parents: 3462
diff changeset
42 ## @strong{Default} the default frequency range is selected as follows: (These
5016
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4946
diff changeset
43 ## 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
44 ## @enumerate
3438
2e06c3941943 [project @ 2000-01-14 06:33:18 by jwe]
jwe
parents: 3431
diff changeset
45 ## @item via routine __bodquist__, isolate all poles and zeros away from
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
46 ## @var{w}=0 (@var{jw}=0 or @math{@code{exp}(jwT)}=1) and select the frequency
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
47 ## range based on the breakpoint locations of the frequencies.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
48 ## @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
49 ## to @math{jwT} in
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
50 ## @ifinfo
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
51 ## [0,2 pi /T]
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
52 ## @end ifinfo
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
53 ## @iftex
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
54 ## @tex
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
55 ## $[0,2\pi/T]$
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
56 ## @end tex
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
57 ## @end iftex
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
58 ## @item A "smoothing" routine is used to ensure that the plot phase does
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
59 ## not change excessively from point to point and that singular
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
60 ## points (e.g., crossovers from +/- 180) are accurately shown.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
61 ##
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
62 ## @end enumerate
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
63 ## @item out_idx
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
64 ## @itemx in_idx
3455
f758be6e1730 [project @ 2000-01-18 19:57:12 by hodelas]
hodelas
parents: 3438
diff changeset
65 ##
f758be6e1730 [project @ 2000-01-18 19:57:12 by hodelas]
hodelas
parents: 3438
diff changeset
66 ## The names or indices of outputs and inputs to be used in the frequency
f758be6e1730 [project @ 2000-01-18 19:57:12 by hodelas]
hodelas
parents: 3438
diff changeset
67 ## response. See @code{sysprune}.
f758be6e1730 [project @ 2000-01-18 19:57:12 by hodelas]
hodelas
parents: 3438
diff changeset
68 ##
3462
04aef7306dca [project @ 2000-01-19 17:16:43 by hodelas]
hodelas
parents: 3455
diff changeset
69 ## @strong{Example}
3455
f758be6e1730 [project @ 2000-01-18 19:57:12 by hodelas]
hodelas
parents: 3438
diff changeset
70 ## @example
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4771
diff changeset
71 ## bode(sys,[],"y_3", @{"u_1","u_4"@});
3455
f758be6e1730 [project @ 2000-01-18 19:57:12 by hodelas]
hodelas
parents: 3438
diff changeset
72 ## @end example
3431
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 ## @strong{Outputs}
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
75 ## @table @var
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
76 ## @item mag
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
77 ## @itemx phase
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
78 ## the magnitude and phase of the frequency response @math{G(jw)} or
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
79 ## @math{G(@code{exp}(jwT))} at the selected frequency values.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
80 ## @item w
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
81 ## the vector of frequency values used
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
82 ## @end table
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
83 ##
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
84 ## @enumerate
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
85 ## @item If no output arguments are given, e.g.,
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
86 ## @example
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
87 ## bode(sys);
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
88 ## @end example
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
89 ## bode plots the results to the screen. Descriptive labels are
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
90 ## automatically placed.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
91 ##
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
92 ## Failure to include a concluding semicolon will yield some garbage
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
93 ## being printed to the screen (@code{ans = []}).
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
94 ##
5016
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 4946
diff changeset
95 ## @item If the requested plot is for an @acronym{MIMO} system, mag is set to
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
96 ## @math{||G(jw)||} or @math{||G(@code{exp}(jwT))||}
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
97 ## and phase information is not computed.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
98 ## @end enumerate
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
99 ## @end deftypefn
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 ## Author: John Ingram <ingraje@eng.auburn.edu>
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
102 ## Created: July 10, 1996
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
103 ## Based on previous code by R. Bruce Tenison, July 13, 1994
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
104 ## Modified by David Clem November 13, 1994
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
105 ## again by A. S. Hodel July 1995 (smart plot range, etc.)
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
106 ## Modified by Kai P. Mueller September 28, 1997 (multiplot mode)
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
107
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
108 function [mag_r, phase_r, w_r] = bode (sys, w, outputs, inputs, plot_style)
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
109
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
110 ## check number of input arguments given
6447
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
111 if (nargin < 1 || nargin > 5)
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5926
diff changeset
112 print_usage ();
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
113 endif
6447
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
114 if (nargin < 2)
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
115 w = [];
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
116 endif
6447
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
117 if (nargin < 3)
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
118 outputs = [];
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
119 endif
6447
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
120 if (nargin < 4)
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
121 inputs = [];
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
122 endif
6447
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
123 if (nargin < 5)
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
124 plot_style = "dB";
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
125 endif
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
126
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
127 if (strcmp (plot_style, "dB"))
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
128 do_db_plot = 1;
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
129 elseif (strcmp (plot_style, "mag"))
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
130 do_db_plot = 0;
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
131 else
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
132 error ("bode: invalid value of plot_style specified");
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
133 endif
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
134
3455
f758be6e1730 [project @ 2000-01-18 19:57:12 by hodelas]
hodelas
parents: 3438
diff changeset
135 [f, w, sys] = __bodquist__ (sys, w, outputs, inputs, "bode");
6447
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
136 bode_nin = sysdimensions (sys, "in");
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
137 bode_nout = sysdimensions (sys, "out");
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
138
6447
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
139 [stname, inname, outname] = sysgetsignals (sys);
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
140 systsam = sysgettsam (sys);
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
141
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
142 ## Get the magnitude and phase of f.
6447
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
143 mag = abs (f);
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
144 phase = unwrap (arg (f)) * 180.0 / pi;
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
145
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
146 if (nargout < 1),
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
147 ## Plot the information
6447
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
148 if (is_digital (sys))
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
149 xlstr = sprintf ("Digital frequency w=rad/sec. pi/T=%g", pi/systsam);
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
150 tistr = "(exp(jwT)) ";
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
151 else
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
152 xlstr = "Frequency in rad/sec";
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
153 tistr = "(jw)";
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
154 endif
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
155
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
156 wv = [min(w), max(w)];
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
157
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
158 is_siso_sys = is_siso (sys);
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
159 max_mag_positive = max (mag) > 0;
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
160
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
161 if (is_siso_sys)
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
162 subplot (2, 1, 1);
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
163 endif
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
164
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
165 if (do_db_plot)
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
166 md = 20 * log10 (mag);
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
167 semilogx (w, md);
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
168 if (max_mag_positive)
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
169 ylabel ("Gain in dB");
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
170 axvec = axis2dlim ([w(:), md(:)]);
3603
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
171 axvec(1:2) = wv;
6447
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
172 axis (axvec);
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
173 endif
6447
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
174 else
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
175 loglog (w, mag);
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
176 ylabel ("Gain |Y/U|")
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
177 endif
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
178 xlabel (xlstr);
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
179 grid ("on");
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
180
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
181 if (is_siso_sys)
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
182 title (sprintf ("|[Y/U]%s|, u=%s, y=%s", tistr, inname{1}, outname{1}));
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
183 else
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
184 title (sprintf ("||Y(%s)/U(%s)||", tistr, tistr));
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
185 disp ("MIMO plot from")
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
186 disp (__outlist__(inname," "));
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
187 disp ("to")
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
188 disp (__outlist__(outname," "));
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
189 endif
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
190
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
191 if (is_siso_sys)
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
192 subplot (2, 1, 2);
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
193 axvec = axis2dlim ([w(:), phase(:)]);
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
194 axvec(1:2) = wv;
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
195 semilogx (w, phase);
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
196 axis (axvec);
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
197 xlabel (xlstr);
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
198 ylabel ("Phase in deg");
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
199 title (sprintf ("phase([Y/U]%s), u=%s, y=%s",
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
200 tistr, inname{1}, outname{1}));
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
201 grid ("on");
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
202 endif
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
203 else
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
204 mag_r = mag;
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
205 phase_r = phase;
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
206 w_r = w;
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
207 endif
6447
3f79532415b5 [project @ 2007-03-24 00:00:31 by jwe]
jwe
parents: 6446
diff changeset
208
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
209 endfunction