STRTRIM Trim Spaces from a String

Section: String Functions

Usage

Removes the white-spaces at the beginning and end of a string (or a cell array of strings). See isspace for a definition of a white-space. There are two forms for the strtrim function. The first is for single strings
   y = strtrim(strng)

where strng is a string. The second form operates on a cell array of strings

   y = strtrim(cellstr)

and trims each string in the cell array.

Example

Here we apply strtrim to a simple string
--> strtrim('  lot of blank spaces    ');

and here we apply it to a cell array

--> strtrim({'  space','enough ',' for ',''})
ans = 
  <cell array> - size: [1 4]
 
Columns 1 to 3
 space    enough    for    
 
Columns 4 to 4
 []