By specifying a format string of '%s', you effectively asked textscan for a single output. But then you asked to read a string 5 times. Consequently output is a single cell which contains five things. Those five things are themselves cells, which contain the strings you want. (Confused?)
So to get the third header, do
Or, you could do
textscan(fid, '%s%s%s%s%s', 1, ...
In which case you will get back 5 cells. But then each of them contains a single cell (which contains a string)!
Unfortunately this is just the way textscan works. It makes sense for reading whole columns of data, but not so much for a header line.
You can always do what you were doing and add
Or do it the other way I showed above and add
Either way, then, header will be a 5-element cell array of the strings.
EDIT, attempting to clarify: textscan returns an n-element cell array, where n is the number of format specifiers in the format string. Each cell will contain the contents that were read from the file. If the contents were numeric, you'll just get a numeric array. But if they were strings, you'll get a cell array of strings. That's why you're ending up with cell arrays containing cell arrays.
Best Answer