annotate scripts/control/base/bode.m @ 7016:93c65f2a5668

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