function str = capitalize(str)
% Post: Convert string so each word has just first letter capitalized
% Pre: Input string consists entirely of letters & spaces

str = lower(str);       % Make sure all letters are lowercase
previous = ' ';         % Ensures first letter is capitialized
for k = 1:length(str)   % Check each letter
    if previous == ' ' && isletter(str(k))
        str(k) = upper(str(k));
    end
    previous = str(k);
end
