I am using textscan to read numbers from a CSV file. Some data elements are empty and for these I want "NaN" and this works fine unless the last element in CSV file is empty, i.e. the last character in the file is a coma. When that is the case the last column is one element shorter than the others.
Example:
Data in file:
2016-12-11 08:48:06.885,4,5,-5,-2,3.3,35.52016-12-11 08:48:07.888,4,5,-5,-2,3.3,35.52016-12-11 08:48:08.885,4,5,-5,-2,3.3,35.52016-12-11 08:48:09.885,4,5,-5,-2,3.3,format = '%s%n%n%n%n%n%n';delim = ',';data_raw = textscan(fid, format, 'delimiter', delim);K>> data_raw{1,7}ans = 35.5000 35.5000 35.5000Expected answer = 35.5000 35.5000 35.5000 NaN
Best Answer