Mercurial > hg > octave-lojdl
changeset 3894:d71f92546e45
[project @ 2002-04-10 00:39:03 by jwe]
author | jwe |
---|---|
date | Wed, 10 Apr 2002 00:39:03 +0000 |
parents | abd8659eea11 |
children | d38c7538b954 |
files | scripts/ChangeLog scripts/strings/deblank.m |
diffstat | 2 files changed, 8 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,5 +1,7 @@ 2002-04-09 Paul Kienzle <pkienzle@users.sf.net> + * 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.
--- 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 <Kurt.Hornik@ci.tuwien.ac.at> @@ -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