From: <par...@us...> - 2012-09-12 11:20:25
|
Revision: 10998 http://octave.svn.sourceforge.net/octave/?rev=10998&view=rev Author: paramaniac Date: 2012-09-12 11:20:19 +0000 (Wed, 12 Sep 2012) Log Message: ----------- control: sync draft code Modified Paths: -------------- trunk/octave-forge/main/control/devel/__frequency_response_2__.m trunk/octave-forge/main/control/devel/bode2.m Modified: trunk/octave-forge/main/control/devel/__frequency_response_2__.m =================================================================== --- trunk/octave-forge/main/control/devel/__frequency_response_2__.m 2012-09-12 10:39:10 UTC (rev 10997) +++ trunk/octave-forge/main/control/devel/__frequency_response_2__.m 2012-09-12 11:20:19 UTC (rev 10998) @@ -1,4 +1,4 @@ -## Copyright (C) 2009, 2010 Lukas F. Reichlin +## Copyright (C) 2009, 2010, 2012 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -21,9 +21,9 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: November 2009 -## Version: 0.2 +## Version: 0.4 -% function [H, w] = __frequency_response_2__ (sys, w = [], mimoflag = 0, resptype = 0, wbounds = "std", cellflag = false) +% function [H, w] = __frequency_response__ (sys, w = [], mimoflag = 0, resptype = 0, wbounds = "std", cellflag = false) function [H, w] = __frequency_response_2__ (mimoflag = 0, resptype = 0, wbounds = "std", cellflag = false, varargin) sys_vec = cellfun (@(x) isa (x, "lti"), varargin) # true or false @@ -40,6 +40,7 @@ varargin{sys_idx} + ## check arguments if(! isa (sys, "lti")) error ("frequency_response: first argument sys must be an LTI system"); @@ -50,18 +51,21 @@ endif if (isa (sys, "frd")) - if (isempty (w)) - w = get (sys, "w"); - else + if (! isempty (w)) warning ("frequency_response: second argument w is ignored"); endif + w = get (sys, "w"); + H = __freqresp__ (sys, [], resptype, cellflag); elseif (isempty (w)) # find interesting frequency range w if not specified w = __frequency_vector__ (sys, wbounds); + H = __freqresp__ (sys, w, resptype, cellflag); + elseif (iscell (w) && numel (w) == 2 && issample (w{1}) && issample (w{2})) + w = __frequency_vector__ (sys, wbounds, w{1}, w{2}); + H = __freqresp__ (sys, w, resptype, cellflag); elseif (! is_real_vector (w)) error ("frequency_response: second argument w must be a vector of frequencies"); + else + H = __freqresp__ (sys, w, resptype, cellflag); endif - ## frequency response - H = __freqresp__ (sys, w, resptype, cellflag); - -endfunction \ No newline at end of file +endfunction Modified: trunk/octave-forge/main/control/devel/bode2.m =================================================================== --- trunk/octave-forge/main/control/devel/bode2.m 2012-09-12 10:39:10 UTC (rev 10997) +++ trunk/octave-forge/main/control/devel/bode2.m 2012-09-12 11:20:19 UTC (rev 10998) @@ -1,4 +1,4 @@ -## Copyright (C) 2009, 2010 Lukas F. Reichlin +## Copyright (C) 2009, 2010, 2011, 2012 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -28,6 +28,9 @@ ## @item w ## Optional vector of frequency values. If @var{w} is not specified, ## it is calculated by the zeros and poles of the system. +## Alternatively, the cell @code{@{wmin, wmax@}} specifies a frequency range, +## where @var{wmin} and @var{wmax} denote minimum and maximum frequencies +## in rad/s. ## @end table ## ## @strong{Outputs} @@ -45,7 +48,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: November 2009 -## Version: 0.2 +## Version: 0.4 function [mag_r, pha_r, w_r] = bode2 (varargin) @@ -64,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 @@ -78,14 +75,16 @@ subplot (2, 1, 1) semilogx (w, mag_db) - 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]") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |