I want to change the value of a pair of bytes in a large binary file using the MATLAB command fwrite. What I'm trying to do is open the file with:
fopen(filename,'r+',precision);
Then read the file using:
fread(fid,NUM,'int32');
It all works. As soon as I get to the file position where I want to write (overwrite) the values of the following bytes, I use the command:
fwrite(fid,variable_name,'int32');
Then I close the file:
fclose(fid);
So, I go back and re-read the file, and these bytes have not changed!
So this is not possible? Or is it 'r+'wrong to use?
userXXXXXXX
source
share