| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
S = strtrim(str)
C = strtrim(cstr)
S = strtrim(str) returns a copy of string str with all leading and trailing white-space characters removed. A white-space character is one for which the isspace function returns logical 1 (true).
C = strtrim(cstr) returns a copy of the cell array of strings cstr with all leading and trailing white-space characters removed from each string in the cell array.
Remove the leading white-space characters (spaces and tabs) from str:
str = sprintf(' \t Remove leading white-space')
str =
Remove leading white-space
str = strtrim(str)
str =
Remove leading white-spaceRemove leading and trailing white-space from the cell array of strings:
cstr = {' Trim leading white-space';
'Trim trailing white-space '};
cstr = strtrim(cstr)
cstr =
'Trim leading white-space'
'Trim trailing white-space'isspace, cellstr, deblank, strjust
![]() | strtok | struct | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |