How to save variables as 16-bit signed integers?

4 次查看(过去 30 天)
Hi! I have a dct_blk array and I need to save it as a 16-bit signed integers. I did the following:
A = dct_blk';
fileID = fopen('img03y.dq','w');
fwrite(fileID,A,'integer*2');
fclose(fileID);
I transponse dct_blk because I need to store it in raster order from left-to-right and moving from top-to-bottom. But when I read my saved binary with the following code
fileID = fopen('img03y.dq');
B = fread(fileID,[N M],'uint16');
B = B';
I'm not getting the same values as dct_blk. I'm getting large numbers where the negative values supposed to be. What can I be doing wrong? Any help will be greatly appreciated.
Thank you.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Low-Level File I/O 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by