If you don't need N and T, the simplest approach is probably to eliminate them before the call to TEXTSCAN:
content = fileread( 'myFile.txt' ) ;
isNT = content == 'N' | content = 'T' ;
content(isNT) = ' ' ;
then you can TEXTSCAN type-homogeneous columns:
C = textscan( content, ...
Note the content variable as first argument, as TEXTSCAN accepts both file handles and strings. If you need N and T, we can talk about the post-processing mentioned in my comment above (no time now, but I'll come back later tonight).
If you wanted to process the whole in one shot using REGEXP, here is an example, but keep in mind that REGEXP is overkill for this operation and will take more time to process than a basic TEXTSCAN.
content = fileread( 'myFile.txt' ) ;
pattern = '([\d]+)\)\s+([\d\s:/]{19})\s+([\d\-.]+)([NT]?)\s+([\d\-.]+)([NT]?)' ;
tokens = regexp( content, pattern, 'tokens' ) ;
tokens = reshape( [tokens{:}], numel( tokens{1} ), [] ).' ;
numData = str2double( tokens(:,[1,3,5]) ) ;
strData = tokens(:, [4,6]) ;
timData = datevec(tokens(:,2), 'yyyy/mm/dd HH:MM:SS' ) ;
Best Answer