annotate scripts/control/bode.m @ 3408:ae7adbb591e8

[project @ 2000-01-06 08:29:11 by jwe]
author jwe
date Thu, 06 Jan 2000 08:29:26 +0000
parents 9610d364e444
children 8625164a0a39
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3397
1a8e2c0d627a [project @ 1999-12-18 03:02:18 by jwe]
jwe
parents: 3385
diff changeset
1 ## Copyright (C) 1996, 1998 Auburn University. All rights reserved.
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
2 ##
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
3 ## This file is part of Octave.
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
4 ##
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
6 ## under the terms of the GNU General Public License as published by the
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
7 ## Free Software Foundation; either version 2, or (at your option) any
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
8 ## later version.
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
9 ##
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but WITHOUT
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
11 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
13 ## for more details.
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
14 ##
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
15 ## You should have received a copy of the GNU General Public License
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
16 ## along with Octave; see the file COPYING. If not, write to the Free
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
17 ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
3346
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
18
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
19 ## -*- texinfo -*-
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
20 ## @deftypefn {Function File } {[@var{mag}, @var{phase}, @var{w}] =} bode(@var{sys}@{,@var{w}, @var{out_idx}, @var{in_idx}@})
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
21 ## If no output arguments are given: produce Bode plots of a system; otherwise,
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
22 ## compute the frequency response of a system data structure
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
23 ##
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
24 ## @strong{Inputs}
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
25 ## @table @var
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
26 ## @item sys
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
27 ## a system data structure (must be either purely continuous or discrete;
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
28 ## see is_digital)
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
29 ## @item w
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
30 ## frequency values for evaluation.
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
31 ##
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
32 ## if @var{sys} is continuous, then bode evaluates @math{G(jw)} where
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
33 ## @math{G(s)} is the system transfer function.
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
34 ##
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
35 ## if @var{sys} is discrete, then bode evaluates G(@code{exp}(jwT)), where
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
36 ## @itemize @bullet
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
37 ## @item @var{T}=@code{sysgettsam(@var{sys})} (the system sampling time) and
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
38 ## @item @math{G(z)} is the system transfer function.
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
39 ## @end itemize
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
40 ##
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
41 ## @strong{ Default} the default frequency range is selected as follows: (These
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
42 ## steps are NOT performed if @var{w} is specified)
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
43 ## @enumerate
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
44 ## @item via routine bodquist, isolate all poles and zeros away from
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
45 ## @var{w}=0 (@var{jw}=0 or @math{@code{exp}(jwT)}=1) and select the frequency
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
46 ## range based on the breakpoint locations of the frequencies.
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
47 ## @item if @var{sys} is discrete time, the frequency range is limited
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
48 ## to @math{jwT} in
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
49 ## @ifinfo
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
50 ## [0,2 pi /T]
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
51 ## @end ifinfo
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
52 ## @iftex
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
53 ## @tex
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
54 ## $[0,2\pi/T]$
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
55 ## @end tex
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
56 ## @end iftex
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
57 ## @item A "smoothing" routine is used to ensure that the plot phase does
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
58 ## not change excessively from point to point and that singular
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
59 ## points (e.g., crossovers from +/- 180) are accurately shown.
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
60 ##
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
61 ## @end enumerate
3402
9610d364e444 [project @ 2000-01-05 04:36:38 by jwe]
jwe
parents: 3400
diff changeset
62 ## @item out_idx
9610d364e444 [project @ 2000-01-05 04:36:38 by jwe]
jwe
parents: 3400
diff changeset
63 ## @itemx in_idx
3346
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
64 ## the indices of the output(s) and input(s) to be used in
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
65 ## the frequency response; see @code{sysprune}.
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
66 ## @end table
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
67 ## @strong{Outputs}
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
68 ## @table @var
3402
9610d364e444 [project @ 2000-01-05 04:36:38 by jwe]
jwe
parents: 3400
diff changeset
69 ## @item mag
9610d364e444 [project @ 2000-01-05 04:36:38 by jwe]
jwe
parents: 3400
diff changeset
70 ## @itemx phase
3346
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
71 ## the magnitude and phase of the frequency response
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
72 ## @math{G(jw)} or @math{G(@code{exp}(jwT))} at the selected frequency values.
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
73 ## @item w
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
74 ## the vector of frequency values used
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
75 ## @end table
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
76 ##
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
77 ## @strong{Notes}
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
78 ## @enumerate
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
79 ## @item If no output arguments are given, e.g.,
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
80 ## @example
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
81 ## bode(sys);
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
82 ## @end example
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
83 ## bode plots the results to the
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
84 ## screen. Descriptive labels are automatically placed.
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
85 ##
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
86 ## Failure to include a concluding semicolon will yield some garbage
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
87 ## being printed to the screen (@code{ans = []}).
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
88 ##
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
89 ## @item If the requested plot is for an MIMO system, mag is set to
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
90 ## @math{||G(jw)||} or @math{||G(@code{exp}(jwT))||}
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
91 ## and phase information is not computed.
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
92 ## @end enumerate
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
93 ## @end deftypefn
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3306
diff changeset
94
3398
0f515bc98460 [project @ 1999-12-18 04:21:28 by jwe]
jwe
parents: 3397
diff changeset
95 ## Author: John Ingram <ingraje@eng.auburn.edu>
0f515bc98460 [project @ 1999-12-18 04:21:28 by jwe]
jwe
parents: 3397
diff changeset
96 ## Created: July 10, 1996
0f515bc98460 [project @ 1999-12-18 04:21:28 by jwe]
jwe
parents: 3397
diff changeset
97 ## Based on previous code by R. Bruce Tenison, July 13, 1994
0f515bc98460 [project @ 1999-12-18 04:21:28 by jwe]
jwe
parents: 3397
diff changeset
98 ## Modified by David Clem November 13, 1994
0f515bc98460 [project @ 1999-12-18 04:21:28 by jwe]
jwe
parents: 3397
diff changeset
99 ## again by A. S. Hodel July 1995 (smart plot range, etc.)
0f515bc98460 [project @ 1999-12-18 04:21:28 by jwe]
jwe
parents: 3397
diff changeset
100 ## Modified by Kai P. Mueller September 28, 1997 (multiplot mode)
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
101
3398
0f515bc98460 [project @ 1999-12-18 04:21:28 by jwe]
jwe
parents: 3397
diff changeset
102 function [mag_r, phase_r, w_r] = bode (sys, w, outputs, inputs, plot_style)
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
103
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
104 ## check number of input arguments given
3282
518ea57df2c4 [project @ 1999-10-13 19:00:38 by jwe]
jwe
parents: 3279
diff changeset
105 if (nargin < 1 | nargin > 5)
518ea57df2c4 [project @ 1999-10-13 19:00:38 by jwe]
jwe
parents: 3279
diff changeset
106 usage("[mag,phase,w] = bode(sys[,w,outputs,inputs,plot_style])");
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
107 endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
108 if(nargin < 2)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
109 w = [];
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
110 endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
111 if(nargin < 3)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
112 outputs = [];
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
113 endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
114 if(nargin < 4)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
115 inputs = [];
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
116 endif
3282
518ea57df2c4 [project @ 1999-10-13 19:00:38 by jwe]
jwe
parents: 3279
diff changeset
117 if(nargin < 5)
518ea57df2c4 [project @ 1999-10-13 19:00:38 by jwe]
jwe
parents: 3279
diff changeset
118 plot_style = "dB";
518ea57df2c4 [project @ 1999-10-13 19:00:38 by jwe]
jwe
parents: 3279
diff changeset
119 endif
518ea57df2c4 [project @ 1999-10-13 19:00:38 by jwe]
jwe
parents: 3279
diff changeset
120
518ea57df2c4 [project @ 1999-10-13 19:00:38 by jwe]
jwe
parents: 3279
diff changeset
121 if (strcmp (plot_style, "dB"))
518ea57df2c4 [project @ 1999-10-13 19:00:38 by jwe]
jwe
parents: 3279
diff changeset
122 do_db_plot = 1;
518ea57df2c4 [project @ 1999-10-13 19:00:38 by jwe]
jwe
parents: 3279
diff changeset
123 elseif (strcmp (plot_style, "mag"))
518ea57df2c4 [project @ 1999-10-13 19:00:38 by jwe]
jwe
parents: 3279
diff changeset
124 do_db_plot = 0;
518ea57df2c4 [project @ 1999-10-13 19:00:38 by jwe]
jwe
parents: 3279
diff changeset
125 else
518ea57df2c4 [project @ 1999-10-13 19:00:38 by jwe]
jwe
parents: 3279
diff changeset
126 error ("bode: invalid value of plot_style specified");
518ea57df2c4 [project @ 1999-10-13 19:00:38 by jwe]
jwe
parents: 3279
diff changeset
127 endif
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
128
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
129 [f, w] = bodquist(sys,w,outputs,inputs,"bode");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
130
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
131 [stname,inname,outname] = sysgetsignals(sys);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
132 systsam = sysgettsam(sys);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
133
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
134 ## Get the magnitude and phase of f.
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
135 mag = abs(f);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
136 phase = arg(f)*180.0/pi;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
137
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
138 if (nargout < 1),
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
139 ## Plot the information
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
140 if(gnuplot_has_multiplot)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
141 oneplot();
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
142 endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
143 gset autoscale;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
144 if(gnuplot_has_multiplot)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
145 gset nokey;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
146 endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
147 clearplot();
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
148 gset data style lines;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
149 if(is_digital(sys))
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
150 xlstr = ["Digital frequency w=rad/sec. pi/T=",num2str(pi/systsam)];
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
151 tistr = "(exp(jwT)) ";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
152 else
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
153 xlstr = "Frequency in rad/sec";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
154 tistr = "(jw)";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
155 endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
156 xlabel(xlstr);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
157 if(is_siso(sys))
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
158 if (gnuplot_has_multiplot)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
159 subplot(2,1,1);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
160 endif
3228
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
161 title(["|[Y/U]",tistr,"|, u=", nth(inname,1),", y=",nth(outname,1)]);
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
162 else
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
163 title([ "||Y(", tistr, ")/U(", tistr, ")||"]);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
164 disp("MIMO plot from")
3228
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
165 disp(outlist(inname," "));
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
166 disp("to")
3228
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
167 disp(outlist(outname," "));
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
168 endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
169 wv = [min(w), max(w)];
3282
518ea57df2c4 [project @ 1999-10-13 19:00:38 by jwe]
jwe
parents: 3279
diff changeset
170 if(do_db_plot && max(mag) > 0)
3236
98e15955107e [project @ 1999-03-05 07:17:10 by jwe]
jwe
parents: 3229
diff changeset
171 ylabel("Gain in dB");
98e15955107e [project @ 1999-03-05 07:17:10 by jwe]
jwe
parents: 3229
diff changeset
172 md = 20*log10(mag);
3306
b3bef983b12d [project @ 1999-10-21 01:48:13 by jwe]
jwe
parents: 3284
diff changeset
173 axvec = axis2dlim([vec(w),vec(md)]);
b3bef983b12d [project @ 1999-10-21 01:48:13 by jwe]
jwe
parents: 3284
diff changeset
174 axvec(1:2) = wv;
b3bef983b12d [project @ 1999-10-21 01:48:13 by jwe]
jwe
parents: 3284
diff changeset
175 axis(axvec);
3236
98e15955107e [project @ 1999-03-05 07:17:10 by jwe]
jwe
parents: 3229
diff changeset
176 else
98e15955107e [project @ 1999-03-05 07:17:10 by jwe]
jwe
parents: 3229
diff changeset
177 ylabel("Gain |Y/U|")
98e15955107e [project @ 1999-03-05 07:17:10 by jwe]
jwe
parents: 3229
diff changeset
178 md = mag;
98e15955107e [project @ 1999-03-05 07:17:10 by jwe]
jwe
parents: 3229
diff changeset
179 endif
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
180
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
181 grid("on");
3282
518ea57df2c4 [project @ 1999-10-13 19:00:38 by jwe]
jwe
parents: 3279
diff changeset
182 if (do_db_plot)
518ea57df2c4 [project @ 1999-10-13 19:00:38 by jwe]
jwe
parents: 3279
diff changeset
183 semilogx(w,md);
518ea57df2c4 [project @ 1999-10-13 19:00:38 by jwe]
jwe
parents: 3279
diff changeset
184 else
518ea57df2c4 [project @ 1999-10-13 19:00:38 by jwe]
jwe
parents: 3279
diff changeset
185 loglog(w,md);
518ea57df2c4 [project @ 1999-10-13 19:00:38 by jwe]
jwe
parents: 3279
diff changeset
186 endif
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
187 if (is_siso(sys))
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
188 if (gnuplot_has_multiplot)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
189 subplot(2,1,2);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
190 else
3400
18366d37e7dd [project @ 1999-12-22 23:36:09 by jwe]
jwe
parents: 3398
diff changeset
191 prompt("Press any key for phase plot");
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
192 endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
193 axvec = axis2dlim([vec(w),vec(phase)]);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
194 axvec(1:2) = wv;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
195 axis(axvec);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
196 xlabel(xlstr);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
197 ylabel("Phase in deg");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
198 title([ "phase([Y/U]", tistr, ...
3228
dbcc24961c44 [project @ 1998-12-09 18:42:12 by jwe]
jwe
parents: 3213
diff changeset
199 "), u=", nth(inname,1),", y=",nth(outname,1)]);
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
200 grid("on");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
201 semilogx(w,phase);
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
202 ## This should be the default for subsequent plot commands.
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
203 if(gnuplot_has_multiplot)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
204 oneplot();
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
205 endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
206 endif
3306
b3bef983b12d [project @ 1999-10-21 01:48:13 by jwe]
jwe
parents: 3284
diff changeset
207 else
b3bef983b12d [project @ 1999-10-21 01:48:13 by jwe]
jwe
parents: 3284
diff changeset
208 mag_r = mag;
b3bef983b12d [project @ 1999-10-21 01:48:13 by jwe]
jwe
parents: 3284
diff changeset
209 phase_r = phase;
b3bef983b12d [project @ 1999-10-21 01:48:13 by jwe]
jwe
parents: 3284
diff changeset
210 w_r = w;
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
211 endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
212 endfunction