This enhancement has been incorporated in Release 2010a (R2010a). For previous product releases, read below for any possible workarounds:
This is a limitation in the TEXTSCAN function in MATLAB in the way it handles -NaN. As a workaround read -NaN as a string using TEXTSCAN, remove the '-' sign and convert it back to a number. The attached MATLAB file"removeminusnan" demonstrates this conversion. It accepts a filename (that contains numbers including -NaN) and number of columns of numbers as input and produces a matrix output that contains numbers with -NaN replaced by NaN.
Also attached is a sample text file "Nan.txt" that contains numbers in 5 rows and 4 columns. Call the function "removeminusnan" as below to read the numbers, including -NaN, from the text file:
removeminusnan('Nan.txt',4)
Best Answer