> Obviously, the whitespace is not counted in the formatted file. > It seems to me that this is a bug. I have tried several things, e.g., to > define another delimiter in the textread command, but this did not work.
One would think it should be a bug indeed but unfortunately it isn't. :(
It's defined C input-scanning behavior; you're just not supposed to do that according to C.
The only choice is to do one of the following --
a) If possible create the file as delimited rather than fixed width
b) Read the file in as a single char array and do a global substitution to insert a delimiter then parse the result from memory
c) Any variation of b) such as a line at a time
d) Use regular expressions
e) Write a Fortran mex file to parse the file and return it to Matlab using Fortran fixed-width fields (or, as long as there are not empty fields, list-directed i/o works as well).
I would urge you to add to the clamor by requesting TMW fix this oversight/shortcoming by submitting formal feature request to support at the mathworks.com site. (This has been one of my pet peeves for 20+ yr as regulars at cs-sm will attest :) )