I try to use fread to read a text file
My code is only 2 lines
fid = fopen('1.txt', 'r');
c = fread(fid,'double', skipvalue);
I have tested different format like double, float32, float64 and different skipvalue from 0 to 8, but none of the combination work.
The data is recorded by a c program code
fprintf(file,”%f \n”,sample[i]);
sample data (each row has one data only )
-0.992224
0.932078
-0.474954
-0.659479
-0.994677
-0.380766
-0.643983
0.425023
Try the
textscanfunction orfscanf.freadis the counterpart tofwrite, notfprintf.fscanfis the counterpart tofprintf.If you absolutely must use
fread, you’d read a string (character array) and then usesscanfto extract the numeric data from it.