Home > ctdcal > dewhite.m

dewhite

PURPOSE ^

DEWHITE Dewhite. Strip trailing whitespace.

SYNOPSIS ^

function sout = dewhite(s)

DESCRIPTION ^

DEWHITE Dewhite. Strip trailing whitespace.

   DEWHITE(S) removes leading and trailing white space and any null characters
   from the string S.  A null character is one that has an absolute value of
   0.

   See also DDEWHITE, DEBLANK, DDEBLANK.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function sout = dewhite(s)
0002 %DEWHITE Dewhite. Strip trailing whitespace.
0003 %
0004 %   DEWHITE(S) removes leading and trailing white space and any null characters
0005 %   from the string S.  A null character is one that has an absolute value of
0006 %   0.
0007 %
0008 %   See also DDEWHITE, DEBLANK, DDEBLANK.
0009 
0010 %   Author:      Peter J. Acklam
0011 %   Time-stamp:  2003-10-13 11:12:52 +0200
0012 %   E-mail:      pjacklam@online.no
0013 %   URL:         http://home.online.no/~pjacklam
0014 
0015    error(nargchk(1, 1, nargin));
0016    if ~ischar(s)
0017       error( 'Input must be a string (char array).' );
0018    end
0019 
0020    if isempty(s)
0021       sout = s;
0022       return;
0023    end
0024 
0025    [r, c] = find(~isspace(s));
0026    if size(s, 1) == 1
0027       sout = s(1:max(c));
0028    else
0029       sout = s(:,1:max(c));
0030    end

Generated on Fri 08-Oct-2004 11:57:17 by m2html © 2003