Mercurial > octave-nkf
comparison scripts/control/base/nichols.m @ 6448:2110cc251779
[project @ 2007-03-24 02:47:36 by jwe]
author | jwe |
---|---|
date | Sat, 24 Mar 2007 02:47:36 +0000 |
parents | 34f96dd5441b |
children | 9483da8d87e5 |
comparison
equal
deleted
inserted
replaced
6447:3f79532415b5 | 6448:2110cc251779 |
---|---|
66 ## @item w | 66 ## @item w |
67 ## The vector of frequency values used. | 67 ## The vector of frequency values used. |
68 ## @end table | 68 ## @end table |
69 ## If no output arguments are given, @command{nichols} plots the results to the screen. | 69 ## If no output arguments are given, @command{nichols} plots the results to the screen. |
70 ## Descriptive labels are automatically placed. See @command{xlabel}, | 70 ## Descriptive labels are automatically placed. See @command{xlabel}, |
71 ## @command{ylabel}, @command{title}, and @command{replot}. | 71 ## @command{ylabel}, and @command{title}. |
72 ## | 72 ## |
73 ## Note: if the requested plot is for an @acronym{MIMO} system, @var{mag} is set to | 73 ## Note: if the requested plot is for an @acronym{MIMO} system, @var{mag} is set to |
74 ## @iftex | 74 ## @iftex |
75 ## @tex | 75 ## @tex |
76 ## $ \Vert G(jw) \Vert $ or $ \Vert G( {\rm exp}(jwT) \Vert $ | 76 ## $ \Vert G(jw) \Vert $ or $ \Vert G( {\rm exp}(jwT) \Vert $ |
83 ## @end deftypefn | 83 ## @end deftypefn |
84 | 84 |
85 function [mag, phase, w] = nichols (sys, w, outputs, inputs) | 85 function [mag, phase, w] = 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 |
91 if(nargin < 2) | 91 if (nargin < 2) |
92 w = []; | 92 w = []; |
93 endif | 93 endif |
94 if(nargin < 3) | 94 if (nargin < 3) |
95 outputs = []; | 95 outputs = []; |
96 endif | 96 endif |
97 if(nargin < 4) | 97 if (nargin < 4) |
98 inputs = []; | 98 inputs = []; |
99 endif | 99 endif |
100 | 100 |
101 [f, w, sys] = __bodquist__ (sys, w, outputs, inputs, "nichols"); | 101 [f, w, sys] = __bodquist__ (sys, w, outputs, inputs, "nichols"); |
102 | 102 |
103 [stname,inname,outname] = sysgetsignals(sys); | 103 [stname,inname,outname] = sysgetsignals (sys); |
104 systsam = sysgettsam(sys); | 104 systsam = sysgettsam (sys); |
105 | 105 |
106 ## Get the magnitude and phase of f. | 106 ## Get the magnitude and phase of f. |
107 mag = abs(f); | 107 mag = abs (f); |
108 phase = arg(f)*180.0/pi; | 108 phase = arg (f)*180.0/pi; |
109 | 109 |
110 if (nargout < 1), | 110 if (nargout < 1), |
111 ## Plot the information | 111 ## Plot the information |
112 oneplot(); | 112 |
113 __gnuplot_set__ autoscale; | 113 if (max (mag) > 0) |
114 __gnuplot_set__ nokey; | 114 plot (phase, 20 * log10 (mag)); |
115 clearplot(); | 115 ylabel ("Gain in dB"); |
116 grid("on"); | 116 else |
117 __gnuplot_set__ data style lines; | 117 plot (phase, mag); |
118 if(is_digital(sys)) | 118 ylabel ("Gain |Y/U|") |
119 endif | |
120 | |
121 grid ("on"); | |
122 | |
123 if (is_digital (sys)) | |
119 tistr = "(exp(jwT)) "; | 124 tistr = "(exp(jwT)) "; |
120 else | 125 else |
121 tistr = "(jw)"; | 126 tistr = "(jw)"; |
122 endif | 127 endif |
123 xlabel("Phase (deg)"); | 128 |
124 if(is_siso(sys)) | 129 xlabel ("Phase (deg)"); |
125 title(["Nichols plot of |[Y/U]",tistr,"|, u=", ... | 130 |
126 sysgetsignals(sys,"in",1,1), ", y=",sysgetsignals(sys,"out",1,1)]); | 131 if (is_siso (sys)) |
132 title (sprintf ("Nichols plot of |[Y/U]%s|, u=%s, y=%s", tistr, | |
133 sysgetsignals (sys, "in", 1, 1), | |
134 sysgetsignals (sys, "out", 1, 1)); | |
127 else | 135 else |
128 title([ "||Y(", tistr, ")/U(", tistr, ")||"]); | 136 title ([ "||Y(", tistr, ")/U(", tistr, ")||"]); |
129 printf("MIMO plot from\n%s\nto\n%s\n",__outlist__(inname," "), ... | 137 printf ("MIMO plot from\n%s\nto\n%s\n", __outlist__ (inname, " "), |
130 __outlist__(outname," ")); | 138 __outlist__ (outname, " ")); |
131 endif | |
132 if(max(mag) > 0) | |
133 ylabel("Gain in dB"); | |
134 md = 20*log10(mag); | |
135 else | |
136 ylabel("Gain |Y/U|") | |
137 md = mag; | |
138 endif | 139 endif |
139 | 140 |
140 axvec = axis2dlim([vec(phase),vec(md)]); | 141 axis (axis2dlim ([phase(:), md(:)])); |
141 axis(axvec); | 142 |
142 plot(phase,md); | |
143 mag = phase = w = []; | 143 mag = phase = w = []; |
144 endif | 144 endif |
145 | |
145 endfunction | 146 endfunction |