# HG changeset patch # User jwe # Date 1127414183 0 # Node ID 74804828df1a2013f88da7d528de166056e08f3e # Parent 8d8fc8eff9e61a27c853d6bdcd1b0e0b83021b9f [project @ 2005-09-22 18:36:22 by jwe] diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,12 @@ +2005-09-22 Bill Denney + + * strings/deblank.m: Handle cell arrays. + * strings/split.m: New argument, N, to limit number of splits. + +2005-09-22 Miroslaw Kwasniak + + * plot/__pltopt1__.m: Handle plot colors "w" and "k" separately. + 2005-09-20 "Orestes Mas" * control/base/rlocus.m: Doc fix. diff --git a/scripts/plot/__pltopt1__.m b/scripts/plot/__pltopt1__.m --- a/scripts/plot/__pltopt1__.m +++ b/scripts/plot/__pltopt1__.m @@ -124,6 +124,9 @@ color = char; set_color = 1; endif + elseif (strcmp (char, "k")) + set_color = 1; + color = "-1"; elseif (strcmp (char, "r")) set_color = 1; color = "1"; @@ -139,7 +142,7 @@ elseif (strcmp (char, "c")) set_color = 1; color = "5"; - elseif (strcmp (char, "w") || strcmp (char, "k")) + elseif (strcmp (char, "w")) set_color = 1; color = "6"; elseif (strcmp (char, "*")) diff --git a/scripts/plot/plot.m b/scripts/plot/plot.m --- a/scripts/plot/plot.m +++ b/scripts/plot/plot.m @@ -104,9 +104,9 @@ ## valid in combination with the @code{@@} or @code{-@@} specifiers. ## ## @item @var{c} -## If @var{c} is one of @code{"r"}, @code{"g"}, @code{"b"}, @code{"m"}, -## @code{"c"}, or @code{"w"}, it is interpreted as the plot color (red, -## green, blue, magenta, cyan, or white). +## If @var{c} is one of @code{"k"}, @code{"r"}, @code{"g"}, @code{"b"}, +## @code{"m"}, @code{"c"}, or @code{"w"}, it is interpreted as the plot +## color (black, red, green, blue, magenta, cyan, or white). ## ## @item ";title;" ## Here @code{"title"} is the label for the key. diff --git a/scripts/strings/deblank.m b/scripts/strings/deblank.m --- a/scripts/strings/deblank.m +++ b/scripts/strings/deblank.m @@ -19,15 +19,16 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} deblank (@var{s}) -## Removes the trailing blanks and nulls from the string @var{s}. -## If @var{s} is a matrix, @var{deblank} trims each row to the -## length of longest string. +## Remove trailing blanks and nulls from @var{s}. If @var{s} +## is a matrix, @var{deblank} trims each row to the length of longest +## string. If @var{s} is a cell array, operate recursively on each +## element of the cell array. ## @end deftypefn ## Author: Kurt Hornik ## Adapted-By: jwe -function t = deblank (s) +function s = deblank (s) if (nargin != 1) usage ("deblank (s)"); @@ -37,11 +38,17 @@ k = find (! isspace (s) & s != "\0"); if (isempty (s) || isempty (k)) - t = ""; + s = ""; else - t = s(:,1:ceil (max (k) / rows (s))); + s = s(:,1:ceil (max (k) / rows (s))); endif + elseif (iscell(s)) + + for i = 1:numel (s) + s{i} = deblank (s{i}); + endfor + else error ("deblank: expecting string argument"); endif diff --git a/scripts/strings/split.m b/scripts/strings/split.m --- a/scripts/strings/split.m +++ b/scripts/strings/split.m @@ -18,10 +18,13 @@ ## 02110-1301, USA. ## -*- texinfo -*- -## @deftypefn {Function File} {} split (@var{s}, @var{t}) +## @deftypefn {Function File} {} split (@var{s}, @var{t}, @var{n}) ## Divides the string @var{s} into pieces separated by @var{t}, returning ## the result in a string array (padded with blanks to form a valid -## matrix). For example, +## matrix). If the optional input @var{n} is supplied, split @var{s} +## into at most @var{n} different pieces. +## +## For example, ## ## @example ## split ("Test string", "t") @@ -29,14 +32,24 @@ ## " s " ## "ring" ## @end example +## +## @example +## split ("Test string", "t", 2) +## @result{} "Tes " +## " string" +## @end example ## @end deftypefn ## Author: Kurt Hornik ## Adapted-By: jwe -function m = split (s, t) +function m = split (s, t, n) - if (nargin == 2) + if (nargin == 2 || nargin == 3) + if (nargin == 2) + n = length (s); + endif + if (ischar (s) && ischar (t)) l_s = length (s); @@ -60,6 +73,8 @@ if (length (ind) == 0) m = s; return; + elseif (n - 1 < length(ind)) + ind = ind(1:n-1) endif ind2 = [1, ind+l_t]; ind = [ind, l_s+1]; @@ -80,7 +95,7 @@ error ("split: both s and t must be strings"); endif else - usage ("split (s, t)"); + usage ("split (s, t, n)"); endif endfunction