From: <par...@us...> - 2010-10-30 23:38:41
|
Revision: 7896 http://octave.svn.sourceforge.net/octave/?rev=7896&view=rev Author: paramaniac Date: 2010-10-30 23:38:32 +0000 (Sat, 30 Oct 2010) Log Message: ----------- control: support discrete-time models whose sampling times are unspecified Modified Paths: -------------- trunk/octave-forge/main/control/DESCRIPTION trunk/octave-forge/main/control/devel/@frd/display.m trunk/octave-forge/main/control/devel/@frd/frd.m trunk/octave-forge/main/control/inst/@lti/__lti_group__.m trunk/octave-forge/main/control/inst/@lti/display.m trunk/octave-forge/main/control/inst/@lti/isct.m trunk/octave-forge/main/control/inst/@lti/lti.m trunk/octave-forge/main/control/inst/@lti/norm.m trunk/octave-forge/main/control/inst/@lti/set.m trunk/octave-forge/main/control/inst/@ss/__freqresp__.m trunk/octave-forge/main/control/inst/@ss/display.m trunk/octave-forge/main/control/inst/@ss/ss.m trunk/octave-forge/main/control/inst/@tf/__freqresp__.m trunk/octave-forge/main/control/inst/@tf/tf.m trunk/octave-forge/main/control/inst/__adjust_ss_data__.m trunk/octave-forge/main/control/inst/__frequency_vector__.m trunk/octave-forge/main/control/inst/__time_response__.m trunk/octave-forge/main/control/inst/dlqr.m trunk/octave-forge/main/control/inst/issample.m trunk/octave-forge/main/control/inst/lqr.m trunk/octave-forge/main/control/inst/lsim.m trunk/octave-forge/main/control/inst/ltimodels.m trunk/octave-forge/main/control/inst/margin.m trunk/octave-forge/main/control/inst/place.m Modified: trunk/octave-forge/main/control/DESCRIPTION =================================================================== --- trunk/octave-forge/main/control/DESCRIPTION 2010-10-29 14:44:53 UTC (rev 7895) +++ trunk/octave-forge/main/control/DESCRIPTION 2010-10-30 23:38:32 UTC (rev 7896) @@ -1,11 +1,11 @@ Name: Control Version: 2.0.0 -Date: 2010-09-14 +Date: 2010-10-31 Author: Lukas Reichlin <luk...@gm...> Maintainer: Lukas Reichlin <luk...@gm...> Title: Control Systems -Description: control systems package increasingly based on the SLICOT Fortran library -Depends: octave (>= 3.2.3) +Description: Octave control systems package increasingly based on the SLICOT Fortran library +Depends: octave (>= 3.2.4) Autoload: yes License: GPL version 3 or later Url: http://octave.sf.net, http://www.slicot.org Modified: trunk/octave-forge/main/control/devel/@frd/display.m =================================================================== --- trunk/octave-forge/main/control/devel/@frd/display.m 2010-10-29 14:44:53 UTC (rev 7895) +++ trunk/octave-forge/main/control/devel/@frd/display.m 2010-10-30 23:38:32 UTC (rev 7896) @@ -38,7 +38,7 @@ display (sys.lti); # display sampling time - if (tsam == -1) + if (tsam == -2) disp ("Static gain."); elseif (tsam == 0) disp ("Continuous-time model."); Modified: trunk/octave-forge/main/control/devel/@frd/frd.m =================================================================== --- trunk/octave-forge/main/control/devel/@frd/frd.m 2010-10-29 14:44:53 UTC (rev 7895) +++ trunk/octave-forge/main/control/devel/@frd/frd.m 2010-10-30 23:38:32 UTC (rev 7896) @@ -64,7 +64,7 @@ ## because sys2 needs to be converted to FRD, ## but sys1 contains no valid frequencies. ## * Because of the reasons given above, - ## tsam = -1 and w = -1 don't make sense + ## tsam = -2 and w = -1 don't make sense ## model precedence: frd > ss > zpk > tf > double superiorto ("ss", "zpk", "tf", "double"); @@ -73,7 +73,7 @@ switch (nargin) case 0 # empty objet sys = frd () - tsam = 0; # tsam = -1 is *not* possible + tsam = 0; # tsam = -2 is *not* possible case 1 if (isa (H, "frd")) # already in frd form sys = frd (frdsys) @@ -98,7 +98,7 @@ otherwise # default case argc = numel (varargin); # number of additional arguments after H and w - if (issample (varargin{1}, 0)) # sys = frd (H, w, tsam, "prop1, "val1", ...) + if (issample (varargin{1}, -10)) # sys = frd (H, w, tsam, "prop1, "val1", ...) tsam = varargin{1}; # discrete-time argc--; # tsam is not a property-value pair if (argc > 0) # if there are any properties and values ... Modified: trunk/octave-forge/main/control/inst/@lti/__lti_group__.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/__lti_group__.m 2010-10-29 14:44:53 UTC (rev 7895) +++ trunk/octave-forge/main/control/inst/@lti/__lti_group__.m 2010-10-30 23:38:32 UTC (rev 7896) @@ -36,10 +36,14 @@ if (lti1.tsam == lti2.tsam) retlti.tsam = lti1.tsam; - elseif (lti1.tsam == -1) + elseif (lti1.tsam == -2) retlti.tsam = lti2.tsam; - elseif (lti2.tsam == -1) + elseif (lti2.tsam == -2) retlti.tsam = lti1.tsam; + elseif (lti1.tsam == -1 && lti2.tsam > 0) + retlti.tsam = lti2.tsam; + elseif (lti2.tsam == -1 && lti1.tsam > 0) + retlti.tsam = lti1.tsam; else error ("lti_group: systems must have identical sampling times"); endif Modified: trunk/octave-forge/main/control/inst/@lti/display.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/display.m 2010-10-29 14:44:53 UTC (rev 7895) +++ trunk/octave-forge/main/control/inst/@lti/display.m 2010-10-30 23:38:32 UTC (rev 7896) @@ -26,6 +26,8 @@ if (ltisys.tsam > 0) disp (sprintf ("Sampling time: %g s", ltisys.tsam)); + elseif (ltisys.tsam == -1) + disp ("Sampling time: unspecified"); endif endfunction \ No newline at end of file Modified: trunk/octave-forge/main/control/inst/@lti/isct.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/isct.m 2010-10-29 14:44:53 UTC (rev 7895) +++ trunk/octave-forge/main/control/inst/@lti/isct.m 2010-10-30 23:38:32 UTC (rev 7896) @@ -30,6 +30,6 @@ print_usage (); endif - bool = (ltisys.tsam == 0 || ltisys.tsam == -1); + bool = (ltisys.tsam == 0 || ltisys.tsam == -2); endfunction \ No newline at end of file Modified: trunk/octave-forge/main/control/inst/@lti/lti.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/lti.m 2010-10-29 14:44:53 UTC (rev 7895) +++ trunk/octave-forge/main/control/inst/@lti/lti.m 2010-10-30 23:38:32 UTC (rev 7896) @@ -22,7 +22,7 @@ ## Created: September 2009 ## Version: 0.2 -function ltisys = lti (p = 0, m = 0, tsam = -1) +function ltisys = lti (p = 0, m = 0, tsam = -2) inname = repmat ({""}, m, 1); outname = repmat ({""}, p, 1); Modified: trunk/octave-forge/main/control/inst/@lti/norm.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/norm.m 2010-10-29 14:44:53 UTC (rev 7895) +++ trunk/octave-forge/main/control/inst/@lti/norm.m 2010-10-30 23:38:32 UTC (rev 7896) @@ -104,7 +104,7 @@ if (fpeak(2) > 0) if (discrete) - wpeak = fpeak(1) / tsam; + wpeak = fpeak(1) / abs (tsam); # tsam could be -1 else wpeak = fpeak(1); endif Modified: trunk/octave-forge/main/control/inst/@lti/set.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/set.m 2010-10-29 14:44:53 UTC (rev 7895) +++ trunk/octave-forge/main/control/inst/@lti/set.m 2010-10-30 23:38:32 UTC (rev 7896) @@ -66,7 +66,7 @@ sys.outname = __adjust_labels__ (val, p); case {"tsam", "ts"} - if (issample (val)) + if (issample (val, -1)) sys.tsam = val; warning ("lti: set: use the editing of property ""%s"" with caution", prop); warning (" it may lead to corrupted models"); Modified: trunk/octave-forge/main/control/inst/@ss/__freqresp__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__freqresp__.m 2010-10-29 14:44:53 UTC (rev 7895) +++ trunk/octave-forge/main/control/inst/@ss/__freqresp__.m 2010-10-30 23:38:32 UTC (rev 7896) @@ -30,24 +30,24 @@ error ("ss: freqresp: system must be square for response type %d", resptype); endif - if (tsam > 0) # discrete system - s = num2cell (exp (i * w * tsam)); - else # continuous system + if (isct (sys)) # continuous system s = num2cell (i * w); + else # discrete system + s = num2cell (exp (i * w * abs (tsam))); endif switch (resptype) - case 0 # default system + case 0 # default system H = cellfun (@(x) c/(x*e - a)*b + d, s, "uniformoutput", false); - case 1 # inversed system + case 1 # inversed system H = cellfun (@(x) inv (c/(x*e - a)*b + d), s, "uniformoutput", false); - case 2 # inversed sensitivity + case 2 # inversed sensitivity j = eye (columns (b)); H = cellfun (@(x) j + c/(x*e - a)*b + d, s, "uniformoutput", false); - case 3 # inversed complementary sensitivity + case 3 # inversed complementary sensitivity j = eye (columns (b)); H = cellfun (@(x) j + inv (c/(x*e - a)*b + d), s, "uniformoutput", false); Modified: trunk/octave-forge/main/control/inst/@ss/display.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/display.m 2010-10-29 14:44:53 UTC (rev 7895) +++ trunk/octave-forge/main/control/inst/@ss/display.m 2010-10-30 23:38:32 UTC (rev 7896) @@ -47,7 +47,7 @@ display (sys.lti); # display sampling time - if (tsam == -1) + if (tsam == -2) disp ("Static gain."); elseif (tsam == 0) disp ("Continuous-time model."); Modified: trunk/octave-forge/main/control/inst/@ss/ss.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/ss.m 2010-10-29 14:44:53 UTC (rev 7895) +++ trunk/octave-forge/main/control/inst/@ss/ss.m 2010-10-30 23:38:32 UTC (rev 7896) @@ -118,7 +118,7 @@ endif elseif (nargin > 4) # default case sys = ss (a, b, c, d, "prop1, "val1", ...) argc = numel (varargin); # number of additional arguments after d - if (issample (varargin{1}, 0)) # sys = ss (a, b, c, d, tsam, "prop1, "val1", ...) + if (issample (varargin{1}, -10)) # sys = ss (a, b, c, d, tsam, "prop1, "val1", ...) tsam = varargin{1}; argc--; if (argc > 0) Modified: trunk/octave-forge/main/control/inst/@tf/__freqresp__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/__freqresp__.m 2010-10-29 14:44:53 UTC (rev 7895) +++ trunk/octave-forge/main/control/inst/@tf/__freqresp__.m 2010-10-30 23:38:32 UTC (rev 7896) @@ -26,10 +26,10 @@ [num, den, tsam] = tfdata (sys); - if (tsam > 0) # discrete system - s = num2cell (exp (i * w * tsam)); - else # continuous system + if (isct (sys)) # continuous system s = num2cell (i * w); + else # discrete system + s = num2cell (exp (i * w * abs (tsam))); endif f = @(z) cellfun (@(x, y) polyval (x, z) / polyval (y, z), num, den); Modified: trunk/octave-forge/main/control/inst/@tf/tf.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/tf.m 2010-10-29 14:44:53 UTC (rev 7895) +++ trunk/octave-forge/main/control/inst/@tf/tf.m 2010-10-30 23:38:32 UTC (rev 7896) @@ -79,32 +79,32 @@ function sys = tf (num = {}, den = {}, varargin) ## model precedence: frd > ss > zpk > tf > double - ## inferiorto ("frd", "ss", "zpk"); # error if de-commented. bug in octave? + ## inferiorto ("frd", "ss", "zpk"); # error if de-commented. bug in octave? superiorto ("double"); argc = 0; switch (nargin) case 0 - tsam = -1; - tfvar = "x"; # undefined + tsam = -2; + tfvar = "x"; # undefined case 1 - if (isa (num, "tf")) # already in tf form + if (isa (num, "tf")) # already in tf form sys = num; return; - elseif (isa (num, "lti")) # another lti object + elseif (isa (num, "lti")) # another lti object [sys, numlti] = __sys2tf__ (num); - sys.lti = numlti; # preserve lti properties + sys.lti = numlti; # preserve lti properties return; - elseif (is_real_matrix (num)) # static gain + elseif (is_real_matrix (num)) # static gain num = num2cell (num); num = __vec2tfpoly__ (num); [p, m] = size (num); den = tfpolyones (p, m); - tsam = -1; - tfvar = "x"; # undefined - elseif (ischar (num)) # s = tf ("s") + tsam = -2; + tfvar = "x"; # undefined + elseif (ischar (num)) # s = tf ("s") tfvar = num; num = __vec2tfpoly__ ([1, 0]); den = __vec2tfpoly__ ([1]); @@ -114,24 +114,24 @@ endif case 2 - if (ischar (num) && issample (den)) # z = tf ("z", 0.3) + if (ischar (num) && issample (den, -1)) # z = tf ("z", 0.3) tfvar = num; tsam = den; num = __vec2tfpoly__ ([1, 0]); den = __vec2tfpoly__ ([1]); - else # sys = tf (num, den) + else # sys = tf (num, den) num = __vec2tfpoly__ (num); den = __vec2tfpoly__ (den); tfvar = "s"; tsam = 0; endif - otherwise # default case + otherwise # default case num = __vec2tfpoly__ (num); den = __vec2tfpoly__ (den); argc = numel (varargin); - if (issample (varargin{1}, 0)) # sys = tf (num, den, tsam, "prop1, "val1", ...) + if (issample (varargin{1}, -10)) # sys = tf (num, den, tsam, "prop1, "val1", ...) tsam = varargin{1}; argc--; @@ -146,7 +146,7 @@ if (argc > 0) varargin = varargin(2:end); endif - else # sys = tf (num, den, "prop1, "val1", ...) + else # sys = tf (num, den, "prop1, "val1", ...) tsam = 0; tfvar = "s"; endif Modified: trunk/octave-forge/main/control/inst/__adjust_ss_data__.m =================================================================== --- trunk/octave-forge/main/control/inst/__adjust_ss_data__.m 2010-10-29 14:44:53 UTC (rev 7895) +++ trunk/octave-forge/main/control/inst/__adjust_ss_data__.m 2010-10-30 23:38:32 UTC (rev 7896) @@ -27,7 +27,7 @@ if (isempty (a)) # static system a = []; # avoid [](nx0) or [](0xn) - tsam = -1; + tsam = -2; endif if (isempty (d)) @@ -42,7 +42,7 @@ if (isempty (b) && isempty (c)) # sys = ss ([], [], [], d) b = zeros (0, columns (d)); c = zeros (rows(d), 0); - tsam = -1; + tsam = -2; endif endfunction \ No newline at end of file Modified: trunk/octave-forge/main/control/inst/__frequency_vector__.m =================================================================== --- trunk/octave-forge/main/control/inst/__frequency_vector__.m 2010-10-29 14:44:53 UTC (rev 7895) +++ trunk/octave-forge/main/control/inst/__frequency_vector__.m 2010-10-30 23:38:32 UTC (rev 7896) @@ -41,8 +41,8 @@ zer = zero (sys); pol = pole (sys); - tsam = get (sys, "tsam"); - discrete = (tsam > 0); # static gains (tsam = -1) are continuous + tsam = abs (get (sys, "tsam")); # tsam could be -1 + discrete = ! isct (sys); # static gains (tsam = -2) are assumed continuous ## make sure zer, pol are row vectors pol = reshape (pol, 1, []); Modified: trunk/octave-forge/main/control/inst/__time_response__.m =================================================================== --- trunk/octave-forge/main/control/inst/__time_response__.m 2010-10-29 14:44:53 UTC (rev 7895) +++ trunk/octave-forge/main/control/inst/__time_response__.m 2010-10-30 23:38:32 UTC (rev 7896) @@ -36,6 +36,7 @@ [A, B, C, D, tsam] = ssdata (sys); discrete = ! isct (sys); # static gains are treated as analog systems + tsam = abs (tsam); # use 1 second if tsam is unspecified (-1) if (discrete) if (! isempty (dt)) @@ -156,13 +157,8 @@ stable = isstable (sys); outname = get (sys, "outname"); + outname = __labels__ (outname, "y_"); - if (isempty (outname) || isequal ("", outname{:})) - outname = strseq ("y_", 1 : length (outname)); - else - outname = __mark_empty_names__ (outname); - endif - if (strcmp (resptype, "initial")) cols = 1; else Modified: trunk/octave-forge/main/control/inst/dlqr.m =================================================================== --- trunk/octave-forge/main/control/inst/dlqr.m 2010-10-29 14:44:53 UTC (rev 7895) +++ trunk/octave-forge/main/control/inst/dlqr.m 2010-10-30 23:38:32 UTC (rev 7896) @@ -88,7 +88,7 @@ tsam = 1; # any value > 0 could be used here endif - if (tsam > 0) + if (issample (tsam, -1)) [x, l, g] = dare (a, b, q, r, s, e); else [x, l, g] = care (a, b, q, r, s, e); Modified: trunk/octave-forge/main/control/inst/issample.m =================================================================== --- trunk/octave-forge/main/control/inst/issample.m 2010-10-29 14:44:53 UTC (rev 7895) +++ trunk/octave-forge/main/control/inst/issample.m 2010-10-30 23:38:32 UTC (rev 7896) @@ -28,7 +28,11 @@ ## @item flg = 0 ## Accept real scalars @var{ts} >= 0. ## @item flg = -1 +## Accept real scalars @var{ts} > 0 and @var{ts} == -1. +## @item flg = -10 ## Accept real scalars @var{ts} >= 0 and @var{ts} == -1. +## @item flg = -2 +## Accept real scalars @var{ts} >= 0, @var{ts} == -1 and @var{ts} == -2. ## @end table ## ## @strong{Outputs} @@ -53,12 +57,16 @@ endif switch (flg) - case 1 # refuse -1 and 0 + case 1 # discrete bool = is_real_scalar (tsam) && (tsam > 0); - case 0 # allow 0, refuse -1 + case 0 # continuous or discrete bool = is_real_scalar (tsam) && (tsam >= 0); - case -1 # allow -1 and 0 + case -1 # discrete, tsam unspecified + bool = is_real_scalar (tsam) && (tsam > 0 || tsam == -1); + case -10 # continuous or discrete, tsam unspecified bool = is_real_scalar (tsam) && (tsam >= 0 || tsam == -1); + case -2 # accept static gains + bool = is_real_scalar (tsam) && (tsam >= 0 || tsam == -1 || tsam == -2); otherwise print_usage (); endswitch @@ -67,8 +75,8 @@ ## flg == 1 -%!assert (issample (1), true) -%!assert (issample (pi), true) +%!assert (issample (1)) +%!assert (issample (pi)) %!assert (issample (0), false) %!assert (issample (-1), false) %!assert (issample (-1, 1), false) @@ -77,20 +85,20 @@ %!assert (issample (2+2i), false) ## flg == 0 -%!assert (issample (1, 0), true) -%!assert (issample (0, 0), true) +%!assert (issample (1, 0)) +%!assert (issample (0, 0)) %!assert (issample (-1, 0), false) -%!assert (issample (pi, 0), true) +%!assert (issample (pi, 0)) %!assert (issample ("b", 0), false) %!assert (issample (rand (3,2), 0), false) %!assert (issample (2+2i, 0), false) %!assert (issample (0+2i, 0), false) ## flg == -1 -%!assert (issample (-1, -1), true) -%!assert (issample (0, -1), true) -%!assert (issample (1, -1), true) -%!assert (issample (pi, -1), true) +%!assert (issample (-1, -1)) +%!assert (issample (0, -1), false) +%!assert (issample (1, -1)) +%!assert (issample (pi, -1)) %!assert (issample (-pi, -1), false) %!assert (issample ("b", -1), false) %!assert (issample (rand (3,2), -1), false) Modified: trunk/octave-forge/main/control/inst/lqr.m =================================================================== --- trunk/octave-forge/main/control/inst/lqr.m 2010-10-29 14:44:53 UTC (rev 7895) +++ trunk/octave-forge/main/control/inst/lqr.m 2010-10-30 23:38:32 UTC (rev 7896) @@ -89,7 +89,7 @@ tsam = 0; endif - if (tsam > 0) + if (issample (tsam, -1)) [x, l, g] = dare (a, b, q, r, s, e); else [x, l, g] = care (a, b, q, r, s, e); Modified: trunk/octave-forge/main/control/inst/lsim.m =================================================================== --- trunk/octave-forge/main/control/inst/lsim.m 2010-10-29 14:44:53 UTC (rev 7895) +++ trunk/octave-forge/main/control/inst/lsim.m 2010-10-30 23:38:32 UTC (rev 7896) @@ -68,6 +68,7 @@ [A, B, C, D, tsam] = ssdata (sys); discrete = ! isct (sys); # static gains are treated as analog systems + tsam = abs (tsam); # use 1 second as default if tsam is unspecified (-1) urows = rows (u); ucols = columns (u); @@ -137,13 +138,8 @@ if (! nargout) # plot information str = "Linear Simulation Results"; outname = get (sys, "outname"); + outname = __labels__ (outname, "y_"); - if (isempty (outname) || isequal ("", outname{:})) - outname = strseq ("y_", 1 : length (outname)); - else - outname = __mark_empty_names__ (outname); - endif - if (discrete) # discrete system for k = 1 : p subplot (p, 1, k); Modified: trunk/octave-forge/main/control/inst/ltimodels.m =================================================================== --- trunk/octave-forge/main/control/inst/ltimodels.m 2010-10-29 14:44:53 UTC (rev 7895) +++ trunk/octave-forge/main/control/inst/ltimodels.m 2010-10-30 23:38:32 UTC (rev 7896) @@ -73,13 +73,13 @@ ## isct, isdt %!shared ltisys %! ltisys = tf (12); -%!assert (ltisys.ts, -1); +%!assert (ltisys.ts, -2); %!assert (isct (ltisys)); %!assert (isdt (ltisys)); %!shared ltisys %! ltisys = ss (17); -%!assert (ltisys.ts, -1); +%!assert (ltisys.ts, -2); %!assert (isct (ltisys)); %!assert (isdt (ltisys)); Modified: trunk/octave-forge/main/control/inst/margin.m =================================================================== --- trunk/octave-forge/main/control/inst/margin.m 2010-10-29 14:44:53 UTC (rev 7895) +++ trunk/octave-forge/main/control/inst/margin.m 2010-10-30 23:38:32 UTC (rev 7896) @@ -140,12 +140,14 @@ endif ## get transfer function - [num, den, Ts] = tfdata (sys); + [num, den, tsam] = tfdata (sys); + continuous = isct (sys); + tsam = abs (tsam); # use 1 second as default if tsam == -1 num = num{1, 1}; den = den{1, 1}; - if (Ts == 0) # CONTINUOUS SYSTEM + if (continuous) # CONTINUOUS SYSTEM ## create polynomials s -> jw l_num = length (num); @@ -162,7 +164,7 @@ w = roots (gm_poly); ## filter results - [gamma, w_gamma] = gm_filter (w, num, den, Ts, tol); + [gamma, w_gamma] = gm_filter (w, num, den, tsam, tol, continuous); ## PHASE MARGIN ## create pm polynomials @@ -179,7 +181,7 @@ w = roots (pm_poly); ## filter results - [phi, w_phi] = pm_filter (w, num, den, Ts, tol); + [phi, w_phi] = pm_filter (w, num, den, tsam, tol, continuous); else # DISCRETE SYSTEM @@ -218,8 +220,8 @@ if (length (idx) > 0) # if z with magnitude 1 exist z_gm = z(idx); - w = log (z_gm) / (i*Ts); # get frequencies w from z - [gamma, w_gamma] = gm_filter (w, num, den, Ts, tol); + w = log (z_gm) / (i*tsam); # get frequencies w from z + [gamma, w_gamma] = gm_filter (w, num, den, tsam, tol, continuous); else # there are no z with magnitude 1 gamma = Inf; w_gamma = NaN; @@ -244,8 +246,8 @@ if (length (idx) > 0) # if z with magnitude 1 exist z_gm = z(idx); - w = log (z_gm) / (i*Ts); # get frequencies w from z - [phi, w_phi] = pm_filter (w, num, den, Ts, tol); + w = log (z_gm) / (i*tsam); # get frequencies w from z + [phi, w_phi] = pm_filter (w, num, den, tsam, tol, continuous); else # there are no z with magnitude 1 phi = 180; w_phi = NaN; @@ -281,7 +283,7 @@ title_str = sprintf ("GM = %g dB (at %g rad/s), PM = %g deg (at %g rad/s)", gamma_db, w_gamma, phi, w_phi); - if (Ts == 0) + if (continuous) xl_str = "Frequency [rad/s]"; else xl_str = sprintf ("Frequency [rad/s] w_N = %g", pi/Ts); @@ -326,17 +328,17 @@ endfunction -function [gamma, w_gamma] = gm_filter (w, num, den, Ts, tol) +function [gamma, w_gamma] = gm_filter (w, num, den, tsam, tol, continuous) idx = find ((abs (imag (w)) < tol) & (real (w) > 0)); # find frequencies in R+ if (length (idx) > 0) # if frequencies in R+ exist w_gm = real (w(idx)); - if (Ts == 0) + if (continuous) s = num2cell (i * w_gm); else - s = num2cell (exp (i * w_gm * Ts)); + s = num2cell (exp (i * w_gm * tsam)); endif f_resp = cellfun (@(x) polyval (num, x) / polyval (den, x), s, "uniformoutput", false); @@ -372,17 +374,17 @@ endfunction -function [phi, w_phi] = pm_filter (w, num, den, Ts, tol) +function [phi, w_phi] = pm_filter (w, num, den, tsam, tol, continuous) idx = find ((abs (imag (w)) < tol) & (real (w) > 0)); # find frequencies in R+ if (length (idx) > 0) # if frequencies in R+ exist w_pm = real (w(idx)); - if (Ts == 0) + if (continuous) s = num2cell (i * w_pm); else - s = num2cell (exp (i * w_pm * Ts)); + s = num2cell (exp (i * w_pm * tsam)); endif f_resp = cellfun (@(x) polyval (num, x) / polyval (den, x), s, "uniformoutput", false); Modified: trunk/octave-forge/main/control/inst/place.m =================================================================== --- trunk/octave-forge/main/control/inst/place.m 2010-10-29 14:44:53 UTC (rev 7895) +++ trunk/octave-forge/main/control/inst/place.m 2010-10-30 23:38:32 UTC (rev 7896) @@ -89,7 +89,7 @@ p = b; sys = a; [a, b] = dssdata (sys, []); # descriptor matrice e should have no influence - discrete = ! isct (sys); # treat tsam = -1 as continuous system + discrete = ! isct (sys); # treat tsam = -2 as continuous system endif else # place (a, b, p), place (a, b, p, alpha), place (a, b, p, alpha, tol) if (nargin < 3) # nargin > 5 already tested This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |