From: <par...@us...> - 2012-02-09 18:12:31
|
Revision: 9604 http://octave.svn.sourceforge.net/octave/?rev=9604&view=rev Author: paramaniac Date: 2012-02-09 18:12:24 +0000 (Thu, 09 Feb 2012) Log Message: ----------- control: simplify frequency response commands (all except margin which is still missing) Modified Paths: -------------- trunk/octave-forge/main/control/inst/bode.m trunk/octave-forge/main/control/inst/bodemag.m trunk/octave-forge/main/control/inst/nichols.m trunk/octave-forge/main/control/inst/nyquist.m trunk/octave-forge/main/control/inst/sigma.m Modified: trunk/octave-forge/main/control/inst/bode.m =================================================================== --- trunk/octave-forge/main/control/inst/bode.m 2012-02-09 17:47:18 UTC (rev 9603) +++ trunk/octave-forge/main/control/inst/bode.m 2012-02-09 18:12:24 UTC (rev 9604) @@ -48,7 +48,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: November 2009 -## Version: 0.3 +## Version: 0.4 function [mag_r, pha_r, w_r] = bode (sys, w = []) @@ -67,12 +67,6 @@ if (! nargout) mag_db = 20 * log10 (mag); - wv = [min(w), max(w)]; - ax_vec_mag = __axis_limits__ ([reshape(w, [], 1), reshape(mag_db, [], 1)]); - ax_vec_mag(1:2) = wv; - ax_vec_pha = __axis_limits__ ([reshape(w, [], 1), reshape(pha, [], 1)]); - ax_vec_pha(1:2) = wv; - if (isct (sys)) xl_str = "Frequency [rad/s]"; else @@ -81,18 +75,16 @@ subplot (2, 1, 1) semilogx (w, mag_db) - ax = axis; - if (any (isinf (ax_vec_mag))) # catch case purely imaginary poles or zeros - ax_vec_mag(3:4) = ax(3:4); - endif - axis (ax_vec_mag) + axis ("tight") + ylim (__axis_margin__ (ylim)) grid ("on") title (["Bode Diagram of ", inputname(1)]) ylabel ("Magnitude [dB]") subplot (2, 1, 2) semilogx (w, pha) - axis (ax_vec_pha) + axis ("tight") + ylim (__axis_margin__ (ylim)) grid ("on") xlabel (xl_str) ylabel ("Phase [deg]") Modified: trunk/octave-forge/main/control/inst/bodemag.m =================================================================== --- trunk/octave-forge/main/control/inst/bodemag.m 2012-02-09 17:47:18 UTC (rev 9603) +++ trunk/octave-forge/main/control/inst/bodemag.m 2012-02-09 18:12:24 UTC (rev 9604) @@ -46,7 +46,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: November 2009 -## Version: 0.3 +## Version: 0.4 function [mag_r, w_r] = bodemag (sys, w = []) @@ -64,10 +64,6 @@ if (! nargout) mag_db = 20 * log10 (mag); - wv = [min(w), max(w)]; - ax_vec_mag = __axis_limits__ ([reshape(w, [], 1), reshape(mag_db, [], 1)]); - ax_vec_mag(1:2) = wv; - if (isct (sys)) xl_str = "Frequency [rad/s]"; else @@ -75,11 +71,8 @@ endif semilogx (w, mag_db) - ax = axis; - if (any (isinf (ax_vec_mag))) # catch case purely imaginary poles or zeros - ax_vec_mag(3:4) = ax(3:4); - endif - axis (ax_vec_mag) + axis ("tight") + ylim (__axis_margin__ (ylim)) grid ("on") title (["Bode Magnitude Diagram of ", inputname(1)]) xlabel (xl_str) Modified: trunk/octave-forge/main/control/inst/nichols.m =================================================================== --- trunk/octave-forge/main/control/inst/nichols.m 2012-02-09 17:47:18 UTC (rev 9603) +++ trunk/octave-forge/main/control/inst/nichols.m 2012-02-09 18:12:24 UTC (rev 9604) @@ -48,7 +48,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: November 2009 -## Version: 0.3 +## Version: 0.4 function [mag_r, pha_r, w_r] = nichols (sys, w = []) @@ -66,14 +66,11 @@ if (! nargout) mag_db = 20 * log10 (mag); - ax_vec = __axis_limits__ ([reshape(pha, [], 1), reshape(mag_db, [], 1)]); plot (pha, mag_db) - ax = axis; - if (any (isinf (ax_vec))) # catch case purely imaginary poles or zeros - ax_vec(3:4) = ax(3:4); - endif - axis (ax_vec) + axis ("tight") + xlim (__axis_margin__ (xlim)) + ylim (__axis_margin__ (ylim)) grid ("on") title (["Nichols Chart of ", inputname(1)]) xlabel ("Phase [deg]") Modified: trunk/octave-forge/main/control/inst/nyquist.m =================================================================== --- trunk/octave-forge/main/control/inst/nyquist.m 2012-02-09 17:47:18 UTC (rev 9603) +++ trunk/octave-forge/main/control/inst/nyquist.m 2012-02-09 18:12:24 UTC (rev 9604) @@ -48,7 +48,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: November 2009 -## Version: 0.2 +## Version: 0.3 function [re_r, im_r, w_r] = nyquist (sys, w = []) @@ -65,10 +65,10 @@ im = imag (H); if (! nargout) - ax_vec = __axis_limits__ ([re, im; re, -im]); - plot (re, im, "b", re, -im, "r") - axis (ax_vec) + axis ("tight") + xlim (__axis_margin__ (xlim)) + ylim (__axis_margin__ (ylim)) grid ("on") title (["Nyquist Diagram of ", inputname(1)]) xlabel ("Real Axis") Modified: trunk/octave-forge/main/control/inst/sigma.m =================================================================== --- trunk/octave-forge/main/control/inst/sigma.m 2012-02-09 17:47:18 UTC (rev 9603) +++ trunk/octave-forge/main/control/inst/sigma.m 2012-02-09 18:12:24 UTC (rev 9604) @@ -60,7 +60,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: May 2009 -## Version: 0.5 +## Version: 0.6 function [sv_r, w_r] = sigma (sys, w = [], resptype = 0) @@ -80,11 +80,6 @@ ## convert to dB for plotting sv_db = 20 * log10 (sv); - ## determine axes - ax_vec = __axis_limits__ ([reshape(w, [], 1), reshape(min(sv_db, [], 1), [], 1); - reshape(w, [], 1), reshape(max(sv_db, [], 1), [], 1)]); - ax_vec(1:2) = [min(w), max(w)]; - ## determine xlabel if (isct (sys)) xl_str = "Frequency [rad/s]"; @@ -94,15 +89,12 @@ ## plot results semilogx (w, sv_db, "b") - ax = axis; - if (any (isinf (ax_vec))) # catch case purely imaginary poles or zeros - ax_vec(3:4) = ax(3:4); - endif - axis (ax_vec) + axis ("tight") + ylim (__axis_margin__ (ylim)) + grid ("on") title (["Singular Values of ", inputname(1)]) xlabel (xl_str) ylabel ("Singular Values [dB]") - grid ("on") else # return values sv_r = sv; w_r = reshape (w, [], 1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |