function simplifywhitespace

Strip all whitespaces at the beginning and the end, and replace all multiple occurrences of whitespaces by one single space.

Syntax
result = simplifywhitespace(s)

Arguments
s:   The string to be simplified