| Contents | Index |
str = deblank(str)
c = deblank(c)
str = deblank(str) removes all trailing whitespace and null characters from the end of character string str. A whitespace is any character for which the isspace function returns logical 1 (true).
c = deblank(c) when c is a cell array of strings, applies deblank to each element of c.
The deblank function is useful for cleaning up the rows of a character array.
Compose a string str that contains space, tab, and null characters:
NL = char(0); TAB = char(9); str = [NL 32 TAB NL 'AB' 32 NL 'CD' NL 32 TAB NL 32];
Display all characters of the string between | symbols:
['|' str '|']
ans =
| AB CD |Remove trailing whitespace and null characters, and redisplay the string:
newstr = deblank(str);
['|' newstr '|']
ans =
| AB CD|Create a 2-by-2 cell array in which each cell contains a word with trailing blanks:
A{1,1} = 'MATLAB ';
A{1,2} = 'SIMULINK ';
A{2,1} = 'Toolboxes ';
A{2,2} = 'MathWorks '
A =
'MATLAB ' 'SIMULINK '
'Toolboxes ' 'MathWorks '
Remove the trailing blanks and redisplay the cell array:
deblank(A);
A
A =
'MATLAB' 'SIMULINK'
'Toolboxes' 'MathWorks'
Explore how to use MATLAB to make advancements in engineering and science.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |