In Matlab I have a binary file read like this:
fid = fopen('nombrearcihvo', 'r', 'ieee-le')
the contents are short floating, or 32 bits (4 bytes) and to read the first element I use the following:
fread(fid, 1, 'float32')
And throws me 0.6721
But I need to read it in a code in C, and I used the following code
float v;
ifile = fopen(namefileI,"r");
fread((void*)(&v), sizeof(v), 1, ifile);
To see the result I do it by sending the content of v to another file of the form:
fwrite ((void*)(&v), sizeof(v), 1, fp);
And throws these symbols at me: ± ,?
Actually, I have tried several ways, with none that has left me somewhat satisfied since the result does not seem to match the one thrown by Matlab.
My pc is Little-Endian, so I should be reading the same, and the float32 type is the same as 4 bytes of C ....
What code or steps should I take to convert the data in the file and get the same result as in Matlab?
Thanks!