Clear Filters
Clear Filters

How to save variables as 16-bit signed integers?

4 views (last 30 days)
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.

Answers (0)

Community Treasure Hunt

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

Start Hunting!