# HG changeset patch # User jwe # Date 976929913 0 # Node ID 110bc441a9543567ad5fb1dbeedf4cba0feb5d78 # Parent a816be1d1626489638cbf09db109640531bb012f [project @ 2000-12-16 01:25:12 by jwe] diff --git a/PROJECTS b/PROJECTS --- a/PROJECTS +++ b/PROJECTS @@ -440,9 +440,6 @@ * Handle end-of-line comments correctly in parse trees for use with the type command. - * For dynamically linked functions, the which and type commands - should display the location of the .oct file. - * Clean up eye, eval, feval, keyboard, input, ones, zeros. * It would be nice to have an interactive debugger. diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,16 @@ +2000-12-15 Teemu Ikonen + + * strings/index.m: Return 0 if either string is empty. + +2000-12-15 Ben Sapp + + * control/system/c2d.m: Allow option of matched pole/zero + equivalent for conversion. + +2000-12-15 Matthew W. Roberts + + * strings/findstr.m: Return empty matrix if search string is empty. + 2000-12-15 Kai Habel * saveimage.m: Do create rawbit image for black and white images, diff --git a/scripts/control/system/c2d.m b/scripts/control/system/c2d.m --- a/scripts/control/system/c2d.m +++ b/scripts/control/system/c2d.m @@ -46,6 +46,9 @@ ## ## @strong{Note} If the 2nd argument is not a string, @code{c2d} assumes that ## the 2nd argument is @var{t} and performs appropriate argument checks. +## @item "matched" +## Use the matched pole/zero equivalent transformation (currently only +## works for purely continuous SISO systems). ## @end table ## ## @strong{Outputs} @@ -84,6 +87,10 @@ opt = "ex"; endif + if (! isstr (opt)) + error ("expecting option as a string"); + endif + ## check if sampling period T was passed. Ts = sysgettsam(sys); if(!exist("T")) @@ -99,8 +106,10 @@ if (!is_sample(T)) error("sampling period T must be a postive, real scalar"); - elseif( ! (strcmp(opt,"ex") | strcmp(opt,"bi") ) ) - error(["invalid option passed: ",opt]) + elseif (! (strcmp (opt, "ex") + || strcmp (opt, "bi") + || strcmp (opt, "matched"))) + error ("invalid option passed: %s", opt); endif sys = sysupdate(sys,"ss"); @@ -167,9 +176,26 @@ D = d + (c*iab); stnamed = strappend(stname,"_d"); dsys = ss2sys(A,B,C,D,T,0,rows(A),stnamed,inname,outname); + elseif(strcmp(opt,"matched")) + if(is_digital(sys)) + error("c2d: system is already digital"); + elseif((length(sys.inname) != 1) || (length(sys.outname) != 1)) + error("c2d: system in not single input, single output"); + else + sys = sysupdate(sys,"zp"); + p = exp(sys.pol*T); + z = exp(sys.zer*T); + infinite_zeros = max(size(sys.pol))-max(size(sys.zer))-1; + for i = 1:infinite_zeros + z = [z ; -1]; + endfor + ## Should the freaquency we adjust around always be 1? + [cmag,cphase,cw] = bode(sys,1); + [dmag,dpahse,dw] = bode(zp2sys(z,p,1,T),1); + dsys = zp2sys(z,p,cmag/dmag,T); endif else - error(["Bad option=",opt]) + error ("invalid option = %s", opt); endif endfunction diff --git a/scripts/strings/findstr.m b/scripts/strings/findstr.m --- a/scripts/strings/findstr.m +++ b/scripts/strings/findstr.m @@ -60,6 +60,11 @@ l_t = length (t); + if (l_t < 1) + v = []; + return; + endif + ind = 1 : l_t; limit = length (s) - l_t + 1; v = zeros (1, limit); diff --git a/scripts/strings/index.m b/scripts/strings/index.m --- a/scripts/strings/index.m +++ b/scripts/strings/index.m @@ -48,6 +48,10 @@ [nr_s, l_s] = size (s); [nr_t, l_t] = size (t); + if (nr_s == 0 || nr_t == 0) + return; + endif + if (nr_s != 1 || nr_t != 1) error ("index: arguments cannot be string arrays"); endif