MATLAB: Textscan skipping character ‘d’

textscan

So I have this string:
fileName ='Br0HAA2dSJ_752012_1.gcd'
And I want to use textscan to extract the 0, HAA, 2, and d in separate cells
DepVar =textscan(fileName,'Br %f %[THAMS] %d %c');
but in the last cell (DepVar{1,4}) it returns a 'S' instead of the 'd' that I want. What is going on and how do I fix it?
Thanks,
Sid

Best Answer

If I recall correctly, in some versions, a "d" or "D" immediately following an integer may be interpreted as being part of an exponent, just like "e" and "E". Even though the exponent character was not followed by an exponent value (optional sign, and at least one digit), the exponent character was not being backed up over.
There was an interesting manifestation of this about a month ago, in which the code did back up from a 'e' that was not followed by digits, but the library turned it into an 'E' -- that is, the library had recorded that it was in that state but "rebuilt" based upon the state instead of remembering the actual characdter.
Related Question