Home > ctdcal > ddewhite.m

ddewhite

PURPOSE ^

DDEWHITE Double dewhite. Strip both leading and trailing whitespace.

SYNOPSIS ^

function sout = ddewhite(s)

DESCRIPTION ^

DDEWHITE Double dewhite. Strip both leading and trailing whitespace.

   DDEWHITE(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 DEWHITE, DEBLANK, DDEBLANK.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function sout = ddewhite(s)
0002 %DDEWHITE Double dewhite. Strip both leading and trailing whitespace.
0003 %
0004 %   DDEWHITE(S) removes leading and trailing white space and any null
0005 %   characters from the string S.  A null character is one that has an absolute
0006 %   value of 0.
0007 %
0008 %   See also DEWHITE, DEBLANK, DDEBLANK.
0009 
0010 %   Author:      Peter J. Acklam
0011 %   Time-stamp:  2003-10-13 11:12:57 +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(min(c) : max(c));
0028    else
0029       sout = s(:, min(c) : max(c));
0030    end

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