Is it possible to use FSCANF or SSCANF to read ASCII data that contains NaNs and Infs?

2 views (last 30 days)
I would like to know if it is possible to use FSCANF or SSCANF to read ASCII data that contains a NaN's or an Inf.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 17 Nov 2009
On some machines, it is possible to read data that contain NaN's and Inf's.
The following machines can read NaN's and Inf's:
Macintosh
SunOS
Solaris
IBM RS/6000
DEC Alpha/OSF (fscanf only)
The following machines cannot read NaN's and Inf's:
MS-Windows
HP
SGI
If your machine cannot read NaN's and Inf's then you will have to read in the file one line at a time and convert it to its numeric values. For example:
f = fopen('file.dat', 'rt');
tmp = fgetl(f);
fclose(f);

More Answers (0)

Categories

Find more on Characters and Strings in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!