From: <par...@us...> - 2011-09-05 19:14:09
|
Revision: 8502 http://octave.svn.sourceforge.net/octave/?rev=8502&view=rev Author: paramaniac Date: 2011-09-05 19:14:03 +0000 (Mon, 05 Sep 2011) Log Message: ----------- control: add pre-warping option to c2d and d2c Modified Paths: -------------- trunk/octave-forge/main/control/doc/NEWS trunk/octave-forge/main/control/inst/@lti/c2d.m trunk/octave-forge/main/control/inst/@lti/d2c.m trunk/octave-forge/main/control/inst/@ss/__c2d__.m trunk/octave-forge/main/control/inst/@ss/__d2c__.m Modified: trunk/octave-forge/main/control/doc/NEWS =================================================================== --- trunk/octave-forge/main/control/doc/NEWS 2011-09-05 18:02:37 UTC (rev 8501) +++ trunk/octave-forge/main/control/doc/NEWS 2011-09-05 19:14:03 UTC (rev 8502) @@ -5,12 +5,13 @@ =============================================================================== ** @lti/c2d - -- Support for "tustin" method added. + -- Support for "tustin" and "prewarp" method added. -- Improved Texinfo string. ** @lti/d2c -- Discrete to continuous-time conversion added. However, support is - limited to state-space models and the zero-order hold and tustin methods. + limited to state-space models and the zero-order hold, tustin and pre- + warping methods. ** Conversion from descriptor to regular state-space is now performed by SLICOT routine SB10JD. Better numerical results are to be expected over the Modified: trunk/octave-forge/main/control/inst/@lti/c2d.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/c2d.m 2011-09-05 18:02:37 UTC (rev 8501) +++ trunk/octave-forge/main/control/inst/@lti/c2d.m 2011-09-05 19:14:03 UTC (rev 8502) @@ -18,6 +18,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {@var{sys} =} c2d (@var{sys}, @var{tsam}) ## @deftypefnx {Function File} {@var{sys} =} c2d (@var{sys}, @var{tsam}, @var{method}) +## @deftypefnx {Function File} {@var{sys} =} c2d (@var{sys}, @var{tsam}, @var{"prewarp"}, @var{w0}) ## Convert the continuous lti model into its discrete-time equivalent. ## ## @strong{Inputs} @@ -29,11 +30,13 @@ ## @item method ## Optional conversion method. If not specified, default method @var{"zoh"} ## is taken. -## @table @code +## @table @var ## @item "zoh" ## Zero-order hold or matrix exponential. ## @item "tustin", "bilin" ## Bilinear transformation or Tustin approximation. +## @item "prewarp" +## Bilinear transformation with pre-warping at frequency @var{w0}. ## @end table ## @end table ## @@ -48,9 +51,9 @@ ## Created: October 2009 ## Version: 0.2 -function sys = c2d (sys, tsam, method = "std") +function sys = c2d (sys, tsam, method = "std", w0 = 0) - if (nargin < 2 || nargin > 3) + if (nargin < 2 || nargin > 4) print_usage (); endif @@ -70,7 +73,7 @@ error ("c2d: third argument is not a string"); endif - sys = __c2d__ (sys, tsam, method); + sys = __c2d__ (sys, tsam, lower (method), w0); sys.tsam = tsam; -endfunction \ No newline at end of file +endfunction Modified: trunk/octave-forge/main/control/inst/@lti/d2c.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/d2c.m 2011-09-05 18:02:37 UTC (rev 8501) +++ trunk/octave-forge/main/control/inst/@lti/d2c.m 2011-09-05 19:14:03 UTC (rev 8502) @@ -18,6 +18,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {@var{sys} =} d2c (@var{sys}) ## @deftypefnx {Function File} {@var{sys} =} d2c (@var{sys}, @var{method}) +## @deftypefnx {Function File} {@var{sys} =} d2c (@var{sys}, @var{"prewarp"}, @var{w0}) ## Convert the discrete lti model into its continuous-time equivalent. ## ## @strong{Inputs} @@ -27,11 +28,13 @@ ## @item method ## Optional conversion method. If not specified, default method @var{"zoh"} ## is taken. -## @table @code +## @table @var ## @item "zoh" ## Zero-order hold or matrix logarithm. ## @item "tustin", "bilin" ## Bilinear transformation or Tustin approximation. +## @item "prewarp" +## Bilinear transformation with pre-warping at frequency @var{w0}. ## @end table ## @end table ## @@ -46,9 +49,9 @@ ## Created: September 2011 ## Version: 0.1 -function sys = d2c (sys, method = "std") +function sys = d2c (sys, method = "std", w0 = 0) - if (nargin == 0 || nargin > 2) + if (nargin == 0 || nargin > 3) print_usage (); endif @@ -64,7 +67,7 @@ error ("d2c: second argument is not a string"); endif - sys = __d2c__ (sys, sys.tsam, method); + sys = __d2c__ (sys, sys.tsam, lower (method), w0); sys.tsam = 0; endfunction Modified: trunk/octave-forge/main/control/inst/@ss/__c2d__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__c2d__.m 2011-09-05 18:02:37 UTC (rev 8501) +++ trunk/octave-forge/main/control/inst/@ss/__c2d__.m 2011-09-05 19:14:03 UTC (rev 8502) @@ -22,10 +22,10 @@ ## Created: October 2009 ## Version: 0.2 -function sys = __c2d__ (sys, tsam, method = "zoh") +function sys = __c2d__ (sys, tsam, method = "zoh", w0 = 0) - switch (method) - case {"zoh", "std"} + switch (method(1)) + case {"z", "s"} # {"zoh", "std"} [sys.a, sys.b, sys.c, sys.d, sys.e] = __dss2ss__ (sys.a, sys.b, sys.c, sys.d, sys.e); [n, m] = size (sys.b); # n: states, m: inputs ## TODO: use SLICOT MB05OD @@ -33,13 +33,16 @@ sys.a = tmp (1:n, 1:n); # F sys.b = tmp (1:n, n+(1:m)); # G - case {"tustin", "bilin"} + case {"t", "b", "p"} # {"tustin", "bilin", "prewarp"} + if (method(1) == "p") # prewarping + beta = w0 / tan (w0*tsam/2); + else + beta = 2/tsam; + endif [sys.a, sys.b, sys.c, sys.d, sys.e] = __dss2ss__ (sys.a, sys.b, sys.c, sys.d, sys.e); - [sys.a, sys.b, sys.c, sys.d] = slab04md (sys.a, sys.b, sys.c, sys.d, 1, 2/tsam, false); + [sys.a, sys.b, sys.c, sys.d] = slab04md (sys.a, sys.b, sys.c, sys.d, 1, beta, false); ## TODO: descriptor case - ## TODO: case "prewarp" - otherwise error ("ss: c2d: %s is an invalid or missing method", method); endswitch Modified: trunk/octave-forge/main/control/inst/@ss/__d2c__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__d2c__.m 2011-09-05 18:02:37 UTC (rev 8501) +++ trunk/octave-forge/main/control/inst/@ss/__d2c__.m 2011-09-05 19:14:03 UTC (rev 8502) @@ -22,10 +22,10 @@ ## Created: September 2011 ## Version: 0.1 -function sys = __d2c__ (sys, tsam, method = "zoh") +function sys = __d2c__ (sys, tsam, method = "zoh", w0 = 0) - switch (method) - case {"zoh", "std"} + switch (method(1)) + case {"z", "s"} # {"zoh", "std"} [sys.a, sys.b, sys.c, sys.d, sys.e] = __dss2ss__ (sys.a, sys.b, sys.c, sys.d, sys.e); [n, m] = size (sys.b); # n: states, m: inputs tmp = logm ([sys.a, sys.b; zeros(m,n), eye(m)]) / tsam; @@ -35,13 +35,16 @@ sys.a = real (tmp(1:n, 1:n)); sys.b = real (tmp(1:n, n+1:n+m)); - case {"tustin", "bilin"} + case {"t", "b", "p"} # {"tustin", "bilin", "prewarp"} + if (method(1) == "p") # prewarping + beta = w0 / tan (w0*tsam/2); + else + beta = 2/tsam; + endif [sys.a, sys.b, sys.c, sys.d, sys.e] = __dss2ss__ (sys.a, sys.b, sys.c, sys.d, sys.e); - [sys.a, sys.b, sys.c, sys.d] = slab04md (sys.a, sys.b, sys.c, sys.d, 1, 2/tsam, true); + [sys.a, sys.b, sys.c, sys.d] = slab04md (sys.a, sys.b, sys.c, sys.d, 1, beta, true); ## TODO: descriptor case - ## TODO: case "prewarp" - otherwise error ("ss: d2c: %s is an invalid or missing method", method); endswitch This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |