fread and fwrite application in reading file from disk
1 回表示 (過去 30 日間)
古いコメントを表示
hello everyone, can you read data from disk (say a pdf file) with a precision other than uint8 (say integer*4) and then re-write the numerical array back into a meaningful file on the disk?
0 件のコメント
採用された回答
Walter Roberson
2013 年 12 月 6 日
input_data = fread(input_fid, '*uint32');
fwrite(output_fid, input_data);
5 件のコメント
Walter Roberson
2013 年 12 月 7 日
No information should be lost when you convert to 64 bit chunks. However, if you try to do arithmetic on 64 bit integers, and accidentally convert them to double precision in the process, then the result is only going to have 53 bits of precision instead of 64.
For example if you have
X = zeros(1024,1);
X(1:20) = fread(file, 20, '*uint64');
then the data would be read as uint64 but then converted to double to be stored in X because X is double. To fix you would use
X = zeros(1024,1,'uint64')
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!