comparison scripts/control/base/nichols.m @ 6818:9483da8d87e5

[project @ 2007-08-22 08:49:18 by dbateman]
author dbateman
date Wed, 22 Aug 2007 08:49:19 +0000
parents 2110cc251779
children 93c65f2a5668
comparison
equal deleted inserted replaced
6817:2e7f62e52c13 6818:9483da8d87e5
80 ## ||G(jw)|| or ||G(exp(jwT))|| 80 ## ||G(jw)|| or ||G(exp(jwT))||
81 ## @end ifinfo 81 ## @end ifinfo
82 ## and phase information is not computed. 82 ## and phase information is not computed.
83 ## @end deftypefn 83 ## @end deftypefn
84 84
85 function [mag, phase, w] = nichols (sys, w, outputs, inputs) 85 function [mag2, phase2, w2] = nichols (sys, w, outputs, inputs)
86 86
87 ## check number of input arguments given 87 ## check number of input arguments given
88 if (nargin < 1 || nargin > 4) 88 if (nargin < 1 || nargin > 4)
89 print_usage (); 89 print_usage ();
90 endif 90 endif
109 109
110 if (nargout < 1), 110 if (nargout < 1),
111 ## Plot the information 111 ## Plot the information
112 112
113 if (max (mag) > 0) 113 if (max (mag) > 0)
114 plot (phase, 20 * log10 (mag)); 114 md = 20 * log10 (mag);
115 plot (phase, md);
115 ylabel ("Gain in dB"); 116 ylabel ("Gain in dB");
116 else 117 else
117 plot (phase, mag); 118 md = mag;
119 plot (phase, md);
118 ylabel ("Gain |Y/U|") 120 ylabel ("Gain |Y/U|")
119 endif 121 endif
120 122
121 grid ("on"); 123 grid ("on");
122 124
129 xlabel ("Phase (deg)"); 131 xlabel ("Phase (deg)");
130 132
131 if (is_siso (sys)) 133 if (is_siso (sys))
132 title (sprintf ("Nichols plot of |[Y/U]%s|, u=%s, y=%s", tistr, 134 title (sprintf ("Nichols plot of |[Y/U]%s|, u=%s, y=%s", tistr,
133 sysgetsignals (sys, "in", 1, 1), 135 sysgetsignals (sys, "in", 1, 1),
134 sysgetsignals (sys, "out", 1, 1)); 136 sysgetsignals (sys, "out", 1, 1)));
135 else 137 else
136 title ([ "||Y(", tistr, ")/U(", tistr, ")||"]); 138 title ([ "||Y(", tistr, ")/U(", tistr, ")||"]);
137 printf ("MIMO plot from\n%s\nto\n%s\n", __outlist__ (inname, " "), 139 printf ("MIMO plot from\n%s\nto\n%s\n", __outlist__ (inname, " "),
138 __outlist__ (outname, " ")); 140 __outlist__ (outname, " "));
139 endif 141 endif
140 142
141 axis (axis2dlim ([phase(:), md(:)])); 143 axis (axis2dlim ([phase(:), md(:)]));
142 144 else
143 mag = phase = w = []; 145 mag2 = mag;
146 phase2 = phase;
147 w2 = w;
144 endif 148 endif
145 149
146 endfunction 150 endfunction