If you can, read the whole file as a string:
str = fread(fd, inf, '*char');
Replace linefeeds and carriage returns with spaces to make a single
line:
str(str == '\n' | str == '\r') = ' ';
And convert all numbers with a single call to sscanf:
m = sscanf(str, '%g');
Hth,
Yves