Code covered by the BSD License  

Highlights from
Reverse Token Order

from Reverse Token Order by Siddharth Shankar
Reverse the order of words in a string.

reverseTokenOrder(inputString)
function outputString = reverseTokenOrder(inputString)
%REVERSETOKENORDER Reverse the order of tokens (words) in a string.
%   REVERSETOKENORDER(STR) returns a string whose words appear in reverse
%   order compared to the original string, in the left/right direction.
%   
%   See also FLIPLR, FLIPUD, FLIPDIM, ROT90.
%
% Copyright 2009, The MathWorks, Inc.
if(nargin < 1)
   error('MATLAB:reverseTokenOrder:InsufficientArguments','Not enough input arguments.'); 
end %END-IF

if(nargin > 1)
   error('MATLAB:reverseTokenOrder:TooManyArguments','Too many input arguments.'); 
end %END-IF

if(~ischar(inputString) || isempty(inputString))
   error('MATLAB:reverseTokenOrder:IncorrectType','Input must be a non-empty character string'); 
end %END-IF
% Process input string using TEXTSCAN
tokens = textscan(inputString,'%s');

% Generate reversed string
outputString = formReversedString(tokens{:});

end % End of function

function outString = formReversedString(tokens)

outString = '';
for i = numel(tokens):-1:1
    outString = [outString ' ' tokens{i}]; %#ok<AGROW>
end %END-FOR
strtrim(outString);
end % End of function

Contact us at files@mathworks.com