# HG changeset patch # User jwe # Date 1018399143 0 # Node ID d71f92546e45cc24c999fb30f64eb6b246ea2b72 # Parent abd8659eea11a59cbb621d4840b79946c7b016e0 [project @ 2002-04-10 00:39:03 by jwe] diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,5 +1,7 @@ 2002-04-09 Paul Kienzle + * strings/deblank.m: Trim \0 as well as blank. + * scripts/freqz.m: Evaluate a specific range of frequencies expressed in radians or Hz relative to a supplied sample rate. diff --git a/scripts/strings/deblank.m b/scripts/strings/deblank.m --- a/scripts/strings/deblank.m +++ b/scripts/strings/deblank.m @@ -19,7 +19,9 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} deblank (@var{s}) -## Removes the trailing blanks from the string @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. ## @end deftypefn ## Author: Kurt Hornik @@ -33,17 +35,11 @@ if (isstr (s)) - [nr, nc] = size (s); - len = nr * nc; - - if (len == 0) - t = s; - elseif (s == " ") + k = find (s != " " & s != "\0"); + if (isempty (s) || isempty (k)) t = ""; else - s = reshape (s, 1, len); - k = ceil (max (find (s != " ")) / nr) * nr; - t = reshape (s (1:k), nr, k / nr); + t = s(:,1:ceil (max (k) / rows (s))); endif else