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

chr = '     Keep nonbreaking space';
chr = [chr char(160) '     '];

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

['|' chr '|']

%
% Remove the leading and trailing whitespace characters.

newChr = strtrim(chr);

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

['|' newChr '|']

% Copyright 2012 The MathWorks, Inc.