MATLAB: How To Get importdata to Ignore NaN

ignorenanimportdataMATLABnan

i have a text file that looks like this: (attached for reference)
"2014-01-01 23:56:00",3620609,37.8,23.83333,760.9666,11.375,815.4666,0,71493.23,1
"2014-01-01 23:56:30",3620610,41.66667,23.8,761,"NAN","NAN",0,"NAN",1
"2014-01-01 23:57:00",3620611,39.86666,23.73333,760.9666,11.375,815.5999,0,71593.27,1
my code is simply
a=importdata('TEST.txt');
And a becomes a struct.
looking at a.data, it only has two rows, and the third row (along with any other rows) just gets clipped off. How do I get the code to import the next lines? My resultant a.data is below by the way
3620609 37.8000000000000 23.8333300000000 760.966600000000 11.3750000000000 815.466600000000 0 71493.2300000000 1
3620610 41.6666700000000 23.8000000000000 761 NaN NaN NaN NaN NaN

Best Answer

fid = fopen('TEST.txt', 'rt');
datacell = textscan(fid, '%q%f%f%f%f%f%f%f%f%f', 'Delimiter', ',', 'TreatAsEmpty, '"NAN"');
fclose(fid)
You might want to use %D instead of %q if you have R2014b or later; that would convert the date/time into datetime objects
If your version of MATLAB is too old for %q then you can use
'"%[^"]"%f%f%f%f%f%f%f%f%f'
You could also consider using readtable()