changeset 5462:74804828df1a

[project @ 2005-09-22 18:36:22 by jwe]
author jwe
date Thu, 22 Sep 2005 18:36:23 +0000
parents 8d8fc8eff9e6
children ab7973a599cf
files scripts/ChangeLog scripts/plot/__pltopt1__.m scripts/plot/plot.m scripts/strings/deblank.m scripts/strings/split.m
diffstat 5 files changed, 49 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Thu Sep 22 14:14:40 2005 +0000
+++ b/scripts/ChangeLog	Thu Sep 22 18:36:23 2005 +0000
@@ -1,3 +1,12 @@
+2005-09-22  Bill Denney  <denney@seas.upenn.edu>
+
+	* strings/deblank.m: Handle cell arrays.
+	* strings/split.m: New argument, N, to limit number of splits.
+
+2005-09-22  Miroslaw Kwasniak  <mirek@zind.ikem.pwr.wroc.pl>
+
+	* plot/__pltopt1__.m: Handle plot colors "w" and "k" separately.
+
 2005-09-20  "Orestes Mas"  <orestes@tsc.upc.edu>
 
 	* control/base/rlocus.m: Doc fix.
--- a/scripts/plot/__pltopt1__.m	Thu Sep 22 14:14:40 2005 +0000
+++ b/scripts/plot/__pltopt1__.m	Thu Sep 22 18:36:23 2005 +0000
@@ -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, "*"))
--- a/scripts/plot/plot.m	Thu Sep 22 14:14:40 2005 +0000
+++ b/scripts/plot/plot.m	Thu Sep 22 18:36:23 2005 +0000
@@ -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.
--- a/scripts/strings/deblank.m	Thu Sep 22 14:14:40 2005 +0000
+++ b/scripts/strings/deblank.m	Thu Sep 22 18:36:23 2005 +0000
@@ -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 <Kurt.Hornik@wu-wien.ac.at>
 ## 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
--- a/scripts/strings/split.m	Thu Sep 22 14:14:40 2005 +0000
+++ b/scripts/strings/split.m	Thu Sep 22 18:36:23 2005 +0000
@@ -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 <Kurt.Hornik@wu-wien.ac.at>
 ## 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