annotate scripts/control/base/bode.m @ 4946:48a39e2b2ab7

[project @ 2004-08-31 17:27:04 by jwe]
author jwe
date Tue, 31 Aug 2004 17:27:05 +0000
parents 9f7ef92b50b0
children bdbee5282954
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
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
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
17 ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
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
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
42 ## steps are NOT performed if @var{w} is specified)
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 ##
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
94 ## @item If the requested plot is for an MIMO system, mag is set to
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
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
110 if (nargin < 1 | nargin > 5)
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
111 usage("[mag,phase,w] = bode(sys[,w,outputs,inputs,plot_style])");
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
112 endif
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
113 if(nargin < 2)
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
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
116 if(nargin < 3)
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
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
119 if(nargin < 4)
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
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
122 if(nargin < 5)
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");
3462
04aef7306dca [project @ 2000-01-19 17:16:43 by hodelas]
hodelas
parents: 3455
diff changeset
135 bode_nin = sysdimensions(sys,"in");
04aef7306dca [project @ 2000-01-19 17:16:43 by hodelas]
hodelas
parents: 3455
diff changeset
136 bode_nout = sysdimensions(sys,"out");
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
137
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
138 [stname,inname,outname] = sysgetsignals(sys);
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
139 systsam = sysgettsam(sys);
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.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
142 mag = abs(f);
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
143 phase = arg(f)*180.0/pi;
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
3603
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
147 save_automatic_replot = automatic_replot;
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
148 unwind_protect
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
149 automatic_replot = 0;
4422
92be67bc9301 [project @ 2003-06-04 17:43:15 by jwe]
jwe
parents: 3603
diff changeset
150 oneplot();
3603
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
151 gset autoscale;
4422
92be67bc9301 [project @ 2003-06-04 17:43:15 by jwe]
jwe
parents: 3603
diff changeset
152 gset nokey;
3603
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
153 clearplot();
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
154 gset data style lines;
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
155 if(is_digital(sys))
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
156 xlstr = ["Digital frequency w=rad/sec. pi/T=",num2str(pi/systsam)];
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
157 tistr = "(exp(jwT)) ";
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
158 else
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
159 xlstr = "Frequency in rad/sec";
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
160 tistr = "(jw)";
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
161 endif
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
162 xlabel(xlstr);
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
163 if(is_siso(sys))
4422
92be67bc9301 [project @ 2003-06-04 17:43:15 by jwe]
jwe
parents: 3603
diff changeset
164 subplot(2,1,1);
4771
b8105302cfe8 [project @ 2004-02-16 17:45:50 by jwe]
jwe
parents: 4422
diff changeset
165 title(["|[Y/U]",tistr,"|, u=", inname{1},", y=",outname{1}]);
3603
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
166 else
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
167 title([ "||Y(", tistr, ")/U(", tistr, ")||"]);
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
168 disp("MIMO plot from")
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
169 disp(__outlist__(inname," "));
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
170 disp("to")
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
171 disp(__outlist__(outname," "));
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
172 endif
3603
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
173 wv = [min(w), max(w)];
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
174 if(do_db_plot && max(mag) > 0)
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
175 ylabel("Gain in dB");
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
176 md = 20*log10(mag);
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
177 axvec = axis2dlim([vec(w),vec(md)]);
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
178 axvec(1:2) = wv;
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
179 axis(axvec);
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
180 else
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
181 ylabel("Gain |Y/U|")
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
182 md = mag;
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
183 endif
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
184
3603
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
185 grid("on");
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
186 if (do_db_plot)
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
187 semilogx(w,md);
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
188 else
3603
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
189 loglog(w,md);
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
190 endif
3603
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
191 if (is_siso(sys))
4422
92be67bc9301 [project @ 2003-06-04 17:43:15 by jwe]
jwe
parents: 3603
diff changeset
192 subplot(2,1,2);
3603
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
193 axvec = axis2dlim([vec(w),vec(phase)]);
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
194 axvec(1:2) = wv;
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
195 axis(axvec);
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
196 xlabel(xlstr);
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
197 ylabel("Phase in deg");
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
198 title([ "phase([Y/U]", tistr, ...
4771
b8105302cfe8 [project @ 2004-02-16 17:45:50 by jwe]
jwe
parents: 4422
diff changeset
199 "), u=", inname{1},", y=",outname{1}]);
3603
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
200 grid("on");
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
201 semilogx(w,phase);
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
202 ## This should be the default for subsequent plot commands.
4422
92be67bc9301 [project @ 2003-06-04 17:43:15 by jwe]
jwe
parents: 3603
diff changeset
203 oneplot();
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
204 endif
3603
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
205 unwind_protect_cleanup
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
206 automatic_replot = save_automatic_replot;
de4471c26cd3 [project @ 2000-02-29 07:59:54 by jwe]
jwe
parents: 3502
diff changeset
207 end_unwind_protect
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
208 else
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
209 mag_r = mag;
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
210 phase_r = phase;
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
211 w_r = w;
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
212 endif
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
213 endfunction