Documentation of deblankall

Global Index (all files) (short | long) | Local contents | Local Index (files in subdir) (short | long)

Function Synopsis

OutString = deblankall(InString)

Help text

 Remove leading and trailing Spaces from string or cell array of strings

 This function removes spaces in front and at the end of a string
 or cell array of strings. The removed spaces are taken from the 
 definition of isspace.

 Syntax:  OutString = deblankall(InString)

 Input parameter:
   InString   - String or cell array of strings

 Output parameter:
   OutString  - same format as InString without leading and trailing spaces

 See also: deblank

Cross-Reference Information

This function is called by

Listing of function deblankall



% Author:   Hartmut Pohlheim
% History:  17.06.2001  file created


function OutString = deblankall(InString)

   if ~iscell(InString),
      OutString = deblank_string(InString);
   % Special handling of cell arrays, each string is despaced separately
   else
      OutString=cell(size(InString));
      for ideb = prod(size(InString)):-1:1,
         OutString{ideb} = deblank_string(InString{ideb});
      end
   end



   function StringDeblank = deblank_string(StringwithSpaces)
   
      StringDeblank = StringwithSpaces;
      if ~(isempty(StringwithSpaces)),
         [r,c] = find(~(isspace(StringwithSpaces)) & StringwithSpaces ~= 0);
         if isempty(c), StringDeblank = StringwithSpaces([]);
         else StringDeblank = StringwithSpaces(:,min(c):max(c)); end
      end


% End of function
GEATbx: Main page  Tutorial  Algorithms  M-functions  Parameter/Options  Example functions  www.geatbx.com 

This document is part of version 3.7 of the GEATbx: Genetic and Evolutionary Algorithm Toolbox for use with Matlab - www.geatbx.com.
The Genetic and Evolutionary Algorithm Toolbox is not public domain.
© 1994-2005 Hartmut Pohlheim, All Rights Reserved, (support@geatbx.com).