MATLAB: What is the role of the whitespace parameter in the TEXTSCAN function in MATLAB 7.8 (R2009a)


I would like to use the TEXTSCAN funtion in MATLAB 7.8 (R2009a), but do not know the role of the 'whitespace' parameter.

Best Answer

This enhancement has been incorporated in Release 2010b (R2010b). For previous product releases, read below for any possible workarounds:
Whitespace is the default delimiter property when reading strings. When 'whitespace' is not set, strings are parsed between any 'whitespace' characters. When 'whitespace' is set to somethign more specific, like '\n', strings are only parsed between the instances of '\n.'
Note in the below examples how the string format specifier behaves differently:
test1 = textscan('string1 string2', '%s', 1)
test1 = textscan('string1 string2', '%s', 1, 'whitespace','')
%recapture space delimiter
test1 = textscan('string1 string2', '%s', 1, 'whitespace', '', 'delimiter', ' ')