deblank
Removes trailing whitespace from text.
Category: Language Fundamentals > Data Types
Syntax
s2 = deblank(s)
Removes trailing spaces, tabs, newlines and null characters.
Description
Only the end of the text is changed; leading and inner whitespace stay. Text made only of blanks becomes empty. To clean both ends use strtrim.
Input arguments
s- Character vector, cell array of character vectors, string array, or char matrix.
Output arguments
s2- Text of the same type, without trailing blanks. For a char matrix, columns that are blank in every row are removed.
Example
Trailing blanks
['[' deblank('ab ') ']']
deblank({'a ','b '})
size(deblank(' '))
Output
ans = '[ab]'
ans = 1×2 cell
{'a'} {'b'}
ans = 1×2
0 0