%% Keep Trailing Nonbreaking Space Character
% Create a character vector that includes the nonbreaking space character, char(160), as a trailing blank character.

chr = '     MathWorks';
chr = [chr char(160) '     '];

%
% Display chr between | symbols to show the leading and trailing whitespace.

['|' chr '|']

%
% Remove the trailing whitespace characters.

newChr = deblank(chr);

%
% Display newChr between | symbols. deblank removes the trailing space characters, but leaves the nonbreaking space at the end of newChr.

['|' newChr '|']

% Copyright 2012 The MathWorks, Inc.